Detecting when server is unreachable
Detecting when server is unreachable
Very basic question here, I fear I'm probably missing something obvious. How can the client detect when the server is unreachable (perhaps it's down or hasn't been started)? SmartFox.Connect() gets called, but the OnConnection event listener is never triggered. Is there some other event I can listen for, or some property that denotes that a connection was attempted and couldn't be made?
Re: Detecting when server is unreachable
Well, well...maybe I'm not crazy after all! I just went through the connector example line by line, which successfully calls "OnConnection" even when the server is unavailable. The only difference in my project is that I'm using a more recent version of the Unity plugin (2-9-2013). Sure enough, when I reverted to the older version of the plugin from the connector example (4-9-2012), it works. Perhaps a bug was introduced in the most recent update to the Unity plugin?
Re: Detecting when server is unreachable
I am not sure if it was introduced in the last version, because it doesn't seem to work with previous versions as well.
We'll take a closer look before releasing the next update.
Meanwhile a simple workaround is to detect the failure in loading the socket policy. Since this operation is required before starting the connection you can use something like this to detect if the server is online:
We'll take a closer look before releasing the next update.
Meanwhile a simple workaround is to detect the failure in loading the socket policy. Since this operation is required before starting the connection you can use something like this to detect if the server is online:
Code: Select all
if (Application.isWebPlayer || Application.isEditor)
{
if (!Security.PrefetchSocketPolicy(serverName, serverPort, 500))
{
// Handle the problem here...
}
}
Re: Detecting when server is unreachable
UPDATE:
We have a preview release of the Unity API that fixes several issues as discussed in this forums.
Please make sure to download the DLL and try it in your project.
Please let us know if it fixes your problems.
We have a preview release of the Unity API that fixes several issues as discussed in this forums.
Please make sure to download the DLL and try it in your project.
Please let us know if it fixes your problems.
Who is online
Users browsing this forum: No registered users and 22 guests