My standalone version of a SmartFox project can connect without problems with a local SmartFoxServer or one on the network. However, if I compile the web player or switch platform to web player in the build settings, I get nothing.
It seems the SmartFoxClient get's initialized without problems (at least no errors with debug set to true), but the connection is never made. In OnGUI() I check for smartFox.IsConnected() which never returns true. Also, OnConnection is never called. Below the relevant code. I'm trying to setup the connection in Awake(). I copied the code from the Island demo.
Turns out Unity 3 has incorporated more security in the webplayer. In order to make it work, you need to prefetch the policy file with Security.PrefetchSocketPolicy(serverIP, serverPort); However, this breaks compiling for PC Standalone! I therefore added an if statement checking for the platform that the game is running on.
I found this solution in the SmartFox forums (specifically this post). This is the now working code:
I can't make island demo work either on a webplayer.
The sfs pro server won't work. I've replaced the code that
you proposed but I get an error on the
Debug.Log(loginErrorMessage); line.
should I register the delegates and how can I do that?
Any help?