Page 1 of 4

Unity 3.0 and SFS API

Posted: 30 Jun 2010, 06:36
by ThomasLund
Hi,

Just wanted to give a heads up on this one.

I've been testing the SFS API with Unity 3.0 beta 2, and my small tests show no issues (yet).

I will also run the new SFS 2x API through some tests soon, so we can make sure that it works when 3.0 is launched (and SFS2x for that matter)

But you need to be aware of a webplayer security change in Unity 3. All webplayers that use sockets now need a policy server - similar to Flash. So the webplayer contacts a policy server on a specific port on the machine that hosted it - and it has to return a policy file telling the webplayer which machines and ports are allowed to be contacted.

If you dont have this policy server, then your application will _not_ be able to contact the SFS server (or anything else for that matter).

/Thomas

Posted: 07 Jul 2010, 07:38
by ringhino
hi Thomas,

we also received the b2 of Unity3D 3.0.. and we will test soon your APIs to give you feedback asap.

Have you noticed if the mono library bug has been solved?

Re: Unity 3.0 and SFS API

Posted: 08 Jul 2010, 07:47
by sonicviz
ThomasLund wrote:Hi,

Just wanted to give a heads up on this one.

I've been testing the SFS API with Unity 3.0 beta 2, and my small tests show no issues (yet).

I will also run the new SFS 2x API through some tests soon, so we can make sure that it works when 3.0 is launched (and SFS2x for that matter)

But you need to be aware of a webplayer security change in Unity 3. All webplayers that use sockets now need a policy server - similar to Flash. So the webplayer contacts a policy server on a specific port on the machine that hosted it - and it has to return a policy file telling the webplayer which machines and ports are allowed to be contacted.

If you dont have this policy server, then your application will _not_ be able to contact the SFS server (or anything else for that matter).

/Thomas


Hi Thomas,
Could you give some more information on how to implement a policy server in this case?

Many thanks,
sv

Posted: 17 Jul 2010, 12:28
by ThomasLund
Sure thing.

If you look in the SFS silverlight API, I actually have a policy server for that - because it uses the same mechanism as the new Unity webplayer needs. It comes with sources and is super simple.

Unity will also ship one with the documentation. They write about it in there already, but didnt ship with it.

It might even be possible to route policy requests to the SFS server with some network magic and use the build in policy server - but I havent looked if the format is compatible.

Beware that beta 3 has a bug in webplayer builds (I already reported it). So even with a policy server your game would fail to connect with the socket networking. Hope they got it fixed for beta 4.

/Thomas

Posted: 28 Jul 2010, 03:44
by roychr
Thomas, I have the new Beta 3 and my assetbundles are not loading anymore over the web, did you noticed anything like that ?

Also, I would like to ask if the webplayer fully support smartFox from what you know, I seem to not be able to locate specific information on if Unity3d must be a desktop released application to work with SF.

I would pretty much like it to power my next game which is browser based mainly.

Thanks

Posted: 28 Jul 2010, 07:48
by ThomasLund
As you see the last notice in my last message - beta 3 has an error in the security mechanism. Need beta 4.

:-)

/Thomas

Posted: 29 Jul 2010, 08:53
by ericheimburg
I am trying to upgrade to Unity 3 Beta 4 and having trouble -- it connects to SFS now and I get some other messages such as room lists, but it doesn't send any ExtensionResponse events. Any idea what's up?

Posted: 29 Jul 2010, 09:33
by ThomasLund
Will run some more tests on the API as part of the bugtracking for 1.2.6 release. I'm primarily myself using SFS in standalone and iPhone - not web. So any help testing on webplayer will be great.

Posted: 01 Aug 2010, 09:11
by ericheimburg
Not necessarily the highest-pri bug, but here's one: if you previously used a non-ASCII character as your raw custom protocol separator, that no longer works. (We were using a unicode character to separate fields, so that there was no low-ASCII character that needed to be escaped in text strings.)

While we're at it, it would be awesome if there was a way to disable the separator so that it didn't try to parse the string into chunks... maybe by setting the separator to '\0' or something... that's probably more like what SFS 2x is supposed to accomplish, though, I guess.

Posted: 20 Sep 2010, 18:05
by cadamson
Hey Thomas,
Our project runs and connects to SFS fine locally in web player mode. When we publish it to the web it hangs and throws the following error in the webplayer logs:

Code: Select all

Socket connected to 65.241.233.217:843
Problems parsing XML: 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.Xml2obj (System.Xml.XmlNode xmlNode, SmartFoxClientAPI.Data.SFSObject ao, Int32 depth) [0x00000] in <filename unknown>:0

  at SmartFoxClientAPI.Util.SFSObjectSerializer.Deserialize (System.String xmlData) [0x00000] in <filename unknown>:0


Thanks,
Chad

Posted: 21 Sep 2010, 00:14
by appels
yes, in the U3 beta f1 UT has implemented more security into the webplayer. I can connect to smartfox but as soon we send serialized data the webplayer crashes.

Posted: 21 Sep 2010, 07:18
by ThomasLund
Will try to track it down during today and post bug reports to Unity. If you do the same, then we should be covered.

I made a thread on the beta list - post your bug numbers there please.

/Thomas

Posted: 21 Sep 2010, 08:44
by ThomasLund
OK guys - this is important that you respond fast and with as much info as possible.

I just tried to run a build of the tutorial 3 as a webplayer on my local machine.

I have Unity 3 rc1, SFS 1.6.8.

In editor it works (after setting emulated URL)
Making a build&run (so it uses the file://) also works
Putting it on my webserver also works

I use the policy server that Unity recommends in their manual (written in C# by Novell it seems according to the header). I run it using --all, so it allows everything

So - no errors here. Not problems at all, no errors in player.log

Thus I need as much info as you can give. I need configurations, reproducable Unity project, whatever will show me the error. Else I cannot help and cant see a problem to report.

/Thomas

Posted: 21 Sep 2010, 08:55
by ThomasLund
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);
   }

Posted: 21 Sep 2010, 09:49
by appels
here's my test project... sources, builds, smartfox config.
http://www.edje.net/SmartFox-U3f1.zip