Unity 3.0 and SFS API
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Unity 3.0 and SFS API
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
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
Re: Unity 3.0 and SFS API
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
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
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
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
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
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
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
-
- Posts: 26
- Joined: 18 Mar 2010, 07:25
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
-
- Posts: 26
- Joined: 18 Mar 2010, 07:25
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.
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.
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:
Thanks,
Chad
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
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
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
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
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
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:
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);
}
here's my test project... sources, builds, smartfox config.
http://www.edje.net/SmartFox-U3f1.zip
http://www.edje.net/SmartFox-U3f1.zip
Return to “.Net / Unity3D API”
Who is online
Users browsing this forum: No registered users and 2 guests