Unity 3.0 and SFS API

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 21 Sep 2010, 09:51

Super - talking to Lucas from Unity about it. Got the file downloaded and will try to reproduce

/Thomas
stevets
Posts: 60
Joined: 11 Jul 2010, 12:22
Location: USA

Postby stevets » 21 Sep 2010, 09:54

Hi Thomas,

I have tried the SFSIsland Demo with the same configuration that you specified. However, I use a PC with Vista 64 bit and IE8/Google Chrome.

When I run the Unity Editor version of the SFS Island Demo it works fine. No problems. The Novell server shows that the policy is sent to the client.

When I create a webplayer version it crashes after a few seconds. The Novell server, in this case, also shows that the policy file was sent to the client.

I just bought a mac mini so I will try it there to see if that makes any difference.

Steve
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 21 Sep 2010, 10:02

Got it reproduced with appels demo and isolated it down to (I think) a call to CultureInfo().

Will do a few more tests and then talk to Unity about it

Thanks guys

/Thomas
stevets
Posts: 60
Joined: 11 Jul 2010, 12:22
Location: USA

Postby stevets » 21 Sep 2010, 10:04

Great!
Thanks Thomas
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 21 Sep 2010, 10:18

Super simple non-SFS repro case made. So lets see - will try to work with Unity until this sucker is fixed :-D

/Thomas

Code: Select all

using UnityEngine;
using System.Collections;
using System.Globalization;

public class NewBehaviourScript : MonoBehaviour {

   // Use this for initialization
   void Start () {
   }
   
   // Update is called once per frame
   void Update () {
   
   }
   
   string message = "..";
   
   void OnGUI() {
   if (GUI.Button (new Rect (10,10,100,50), "Test")) {
      Debug.Log("Start");
      NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;
        double varValue = double.Parse("75.4", nfi);
      message = "Value: " + varValue;
   }
   GUI.Label (new Rect (10,70,100,20), message);
   
   }
}
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 21 Sep 2010, 12:06

Got a workaround from the Unity boys - will test that soon. Meanwhile they are looking into a permanent fix.

So if you are in need of a workaround, find all the CultureInfo() calls and remove the , false argument. Seems that this particular overload is flagged unsafe for some weird reason.

BTW. I've quick testet Unity 3 rc1 with SFS2X API and no issues there (crossing fingers).

/Thomas
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 21 Sep 2010, 12:14

This is great news and very fast :)
however i don't know what you mean with CultureInfo() calls.
can you post an example ?
stevets
Posts: 60
Joined: 11 Jul 2010, 12:22
Location: USA

Postby stevets » 21 Sep 2010, 12:36

Hi Thomas,

I cannot find any CultureInfo() calls in the SFSIslandDemo.
Do I need to add a statement, explicitly, if it does not exist?

Also, I am not sure if it is relevant, but I found a reference on the Unity forum that might be of interest,
http://forum.unity3d.com/viewtopic.php?p=399468&highlight=cultureinfo#399468
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 21 Sep 2010, 12:42

Its in the API itself - there are several calls to CultureInfo in there, so you have to hack the API sources and not your game.

Or simply wait to see if rc2 fixes the issue :-)
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 21 Sep 2010, 13:28

many thanks Thomas, will wait for rc2 :)
cadamson
Posts: 19
Joined: 27 Sep 2009, 04:00

Postby cadamson » 21 Sep 2010, 14:33

ThomasLund wrote:Also note, that you can also use the SFS server to give you the policy file.

What you need to use is:

Security.PrefetchSocketPolicy(serverIP, serverPort);

where serverIP is the hostname of your SFS server and serverPort is the SFS port (usually 9339)

before making any socket connection.

For tutorial 3 code, you can do like this:

Code: Select all

   void Awake() {
      Application.runInBackground = true;

      if ( SmartFox.IsInitialized() ) {
         smartFox = SmartFox.Connection;
      } else {
         Security.PrefetchSocketPolicy(serverIP, serverPort);
         try {
            smartFox = new SmartFoxClient(debug);
            smartFox.runInQueueMode=true;
         } catch ( Exception e ) {
            loginErrorMessage = e.ToString();
         }
      }

      // Register callback delegate
      SFSEvent.onConnection += OnConnection;
      SFSEvent.onConnectionLost += OnConnectionLost;
      SFSEvent.onLogin += OnLogin;
      SFSEvent.onRoomListUpdate += OnRoomList;
      SFSEvent.onDebugMessage += OnDebugMessage;

      smartFox.Connect(serverIP, serverPort);
   }


OK. When I try Security.PrefetchSocketPolicy(serverIP, serverPort); I can connect to SFS, but when I login it immediately logs me back out. When I use the socket policy server that came with Unity I can login, but then it hangs after getting initial response back from SFS. This is only on published web player files. When I run it from the editor it works fine using either socket policy server!
Chad

INFO | jvm 1 | 2010/09/21 09:52:44 | 09:52:44.562 - [ FINE ] > User [ chad ] logged in
INFO | jvm 1 | 2010/09/21 09:52:44 | 09:52:44.562 - [ INFO ] > [RedBox] Internal event received: loginRequest
INFO | jvm 1 | 2010/09/21 09:52:44 | [collectaville/functions.as]: Event:userLost
INFO | jvm 1 | 2010/09/21 09:52:44 | 09:52:44.734 - [ INFO ] > [RedBox] Internal event received: userLost
INFO | jvm 1 | 2010/09/21 09:52:44 | 09:52:44.734 - [ FINE ] > User [ chad ] removed
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 21 Sep 2010, 14:39

Been testing all day with different variations of standalone policy server and/or SFS server using policy and have not had any problem with it. No difference serving the policy file with either SFS 1.2.6 or SFS2X

When it gets to logging in, the policy part is long past. So must be something else wrong when the server kicks you out

/Thomas
cadamson
Posts: 19
Joined: 27 Sep 2009, 04:00

Postby cadamson » 21 Sep 2010, 14:46

ThomasLund wrote:Been testing all day with different variations of standalone policy server and/or SFS server using policy and have not had any problem with it. No difference serving the policy file with either SFS 1.2.6 or SFS2X

When it gets to logging in, the policy part is long past. So must be something else wrong when the server kicks you out

/Thomas


I will try the CultureInfo() fix.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 21 Sep 2010, 14:54

Yeah - that will definitely hang the webplayer until fixed regardsless of security policy.

/Thomas
cadamson
Posts: 19
Joined: 27 Sep 2009, 04:00

Postby cadamson » 21 Sep 2010, 15:02

ThomasLund wrote:Been testing all day with different variations of standalone policy server and/or SFS server using policy and have not had any problem with it. No difference serving the policy file with either SFS 1.2.6 or SFS2X

When it gets to logging in, the policy part is long past. So must be something else wrong when the server kicks you out

/Thomas


Ok. I did the api fix. Now I can log in using the SFS policy server without immediately getting logged back out, but now it hangs before any players get spawned.

Code: Select all

Platform assembly: C:\Users\Chad\AppData\LocalLow\Unity\WebPlayer\mono\3.x.x\Data\lib\System.dll (this message is harmless)
Platform assembly: C:\Users\Chad\AppData\LocalLow\Unity\WebPlayer\player\3.x.x\Data\lib\CrossDomainPolicyParser.dll (this message is harmless)
Socket connected to 66.240.232.124:9339

Policy for host 66.240.232.124 found in the cache.

   
Unloading 2 unused Assets to reduce memory usage. Loaded Objects now: 5532.
System memory in use: 280.0 MB.
Unloading 0 Unused Serialized files (Serialized files now loaded: 5 / Dirty serialized files: 1)
Loading WebPlayer Assetbundles
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
CharacterGenerator:get_AssetbundleBaseURL()
CharacterGenerator:get_ReadyToUse()
<Start>c__Iterator2:MoveNext()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

About to parse url: http://test.collectaville.com/assetbundles/CharacterElementDatabase.assetbundle

luccheck6

Island Level Started
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
NetworkController:Start()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

Joined Room!
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
NetworkController:OnJoinRoom(Room)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
NetworkController:Update()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

[SFS DEBUG] ERROR: Exception thrown dispatching event. Exception: System.MethodAccessException: Attempt to access a private/protected method failed.

  at System.Security.SecurityManager.ThrowException (System.Exception ex) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.Util.SFSObjectSerializer.Obj2xml (SmartFoxClientAPI.Data.SFSObject ao, Int32 depth, System.String nodeName, System.Text.StringBuilder xmlData) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.Util.SFSObjectSerializer.Obj2xml (SmartFoxClientAPI.Data.SFSObject ao, Int32 depth, System.String nodeName, System.Text.StringBuilder xmlData) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.Util.SFSObjectSerializer.Serialize (SmartFoxClientAPI.Data.SFSObject ao) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.SmartFoxClient.SendXtMessage (System.String xtName, System.String cmd, ICollection paramObj, System.String type, Int32 roomId) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.SmartFoxClient.SendXtMessage (System.String xtName, System.String cmd, ICollection paramObj, System.String type) [0x00000] in <filename unknown>:0

  at NetworkController.GetServerTime () [0x00000] in <filename unknown>:0

  at NetworkController.OnJoinRoom (SmartFoxClientAPI.Data.Room room) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.SmartFoxClient._DispatchEvent (SmartFoxClientAPI.SFSEvent evt) [0x00000] in <filename unknown>:0
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
LoginGUI:OnDebugMessage(String)
SmartFoxClientAPI.OnDebugMessageDelegate:invoke_void__this___string(String)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
NetworkController:Update()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

[SFS DEBUG] ERROR: Exception thrown dispatching event. Exception: System.MethodAccessException: Attempt to access a private/protected method failed.

  at System.Security.SecurityManager.ThrowException (System.Exception ex) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.Util.SFSObjectSerializer.Obj2xml (SmartFoxClientAPI.Data.SFSObject ao, Int32 depth, System.String nodeName, System.Text.StringBuilder xmlData) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.Util.SFSObjectSerializer.Obj2xml (SmartFoxClientAPI.Data.SFSObject ao, Int32 depth, System.String nodeName, System.Text.StringBuilder xmlData) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.Util.SFSObjectSerializer.Serialize (SmartFoxClientAPI.Data.SFSObject ao) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.SmartFoxClient.SendXtMessage (System.String xtName, System.String cmd, ICollection paramObj, System.String type, Int32 roomId) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.SmartFoxClient.SendXtMessage (System.String xtName, System.String cmd, ICollection paramObj, System.String type) [0x00000] in <filename unknown>:0

  at NetworkController.GetServerTime () [0x00000] in <filename unknown>:0

  at NetworkController.OnJoinRoom (SmartFoxClientAPI.Data.Room room) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.SmartFoxClient._DispatchEvent (SmartFoxClientAPI.SFSEvent evt) [0x00000] in <filename unknown>:0
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
NetworkController:OnDebugMessage(String)
SmartFoxClientAPI.OnDebugMessageDelegate:invoke_void__this___string(String)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
NetworkController:Update()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

The class defined in script file named 'CharacterElementHolder' does not match the file name!
UnityEngine.AssetBundle:get_mainAsset()
CharacterGenerator:get_ReadyToUse()
<Start>c__Iterator2:MoveNext()

[..\..\Runtime\Mono\MonoBehaviour.cpp line 1553]
(Filename: ..\..\Runtime\Mono\MonoBehaviour.cpp Line: 1553)

NullReferenceException: Object reference not set to an instance of an object
  at CharacterGenerator.get_ReadyToUse () [0x00000] in <filename unknown>:0

  at PlayerSpawnController+<Start>c__Iterator2.MoveNext () [0x00000] in <filename unknown>:0
 
(Filename:  Line: -1)

Received Get Door Command - Door Id: 3
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
NetworkController:OnExtensionResponse(Object, String)
SmartFoxClientAPI.OnExtensionResponseDelegate:invoke_void__this___object_string(Object, String)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
NetworkController:Update()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

Received Get Door Command - Door Id: 4
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
NetworkController:OnExtensionResponse(Object, String)
SmartFoxClientAPI.OnExtensionResponseDelegate:invoke_void__this___object_string(Object, String)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
NetworkController:Update()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

Received Get Door Command - Door Id: 6
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
NetworkController:OnExtensionResponse(Object, String)
SmartFoxClientAPI.OnExtensionResponseDelegate:invoke_void__this___object_string(Object, String)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
NetworkController:Update()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

Received Get Door Command - Door Id: 4
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
NetworkController:OnExtensionResponse(Object, String)
SmartFoxClientAPI.OnExtensionResponseDelegate:invoke_void__this___object_string(Object, String)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
NetworkController:Update()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

Received Get Door Command - Door Id: 1
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
NetworkController:OnExtensionResponse(Object, String)
SmartFoxClientAPI.OnExtensionResponseDelegate:invoke_void__this___object_string(Object, String)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
NetworkController:Update()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

Received Get Door Command - Door Id: 5
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
NetworkController:OnExtensionResponse(Object, String)
SmartFoxClientAPI.OnExtensionResponseDelegate:invoke_void__this___object_string(Object, String)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
NetworkController:Update()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

Current Time:0
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
NetworkController:syncTrainAnimation(Single, Single, String)
NetworkController:OnExtensionResponse(Object, String)
SmartFoxClientAPI.OnExtensionResponseDelegate:invoke_void__this___object_string(Object, String)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
NetworkController:Update()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)

New Time:-6.425415E+08
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
NetworkController:syncTrainAnimation(Single, Single, String)
NetworkController:OnExtensionResponse(Object, String)
SmartFoxClientAPI.OnExtensionResponseDelegate:invoke_void__this___object_string(Object, String)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
NetworkController:Update()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2551)
[/code]

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 17 guests