Connect to online server from Unity editor
Posted: 11 Jul 2014, 08:31
I am trying to make a Client program with Unity, i can test with the standalone smartfox server but now i need to test with an existing smartfox server online. There is already a client made with Flash and i got the source of this client, so i copied the server name and port from it.
If i test in Unity standalone i get this error :
If i test with Unity for web i get this :
The code i'm using is from the Tris Unity example :
The server has a crossdomain, which is working with flash :
I am doing something wrong ? Do i need to adjust some settings on the server in order to connect from Unity editor directly (without having to upload on the server where is smartfox) ?
Thanks for your help !
If i test in Unity standalone i get this error :
Code: Select all
[SFS DEBUG] TCPSocketLayer: Connection error: No connection could be made because the target machine actively refused it.Code: Select all
Security Exception. Policy file load failed!Code: Select all
[SFS DEBUG] TCPSocketLayer: General exception on connection: Unable to connect, as no valid crossdomain policy was foundCode: Select all
void Awake() {
Application.runInBackground = true;
//StartCoroutine("Login");
// In a webplayer (or editor in webplayer mode) we need to setup security policy negotiation with the server first
if (Application.isWebPlayer || Application.isEditor) {
if (!Security.PrefetchSocketPolicy(serverName, serverPort, 500)) {
Debug.LogError("Security Exception. Policy file load failed!");
}
}
if (SmartFoxConnection.IsInitialized)
{
smartFox = SmartFoxConnection.Connection;
} else {
smartFox = new SmartFox(debug);
}
// Register callback delegate
smartFox.AddEventListener(SFSEvent.CONNECTION, OnConnection);
smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
smartFox.AddEventListener(SFSEvent.LOGIN, OnLogin);
smartFox.AddLogListener(LogLevel.DEBUG, OnDebugMessage);
smartFox.Connect(serverName, serverPort);
}Code: Select all
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>Thanks for your help !