Start a new topic
Answered

Detecting connection status?

What is the recommended way to detect if a connection created using  SWConnection.Instance.Login() is still valid? SWConnection.Instance.Connected still reports true even if I break the connection (for instance by shutting down the local server).

I have tried calling SWConnection.Instance.GetConnectionsInfo and that will throw an Exception if the connection is broken, but this call returns the login information of all logged in users. Should I really use this call?

Best Answer

Here is some helpful information: 


SWConnecion.Instance.GetConnectionsInfo is not relevant to your use case and and should not be used for this.

SWConnection.Instance.Connected does not actually communicate with the server to find out its status. If you pull the cord in your machine, the network card will detect this and will shut down all connections. This is actually not always good. Compare pulling the cord between 2 routers on the way between the client and the server and then putting the cord back. Unless you tried to make a call during the time, the cord was disconnected, the connection will still work.

So by definition, the connection is not considered disconnected until a real call to the server has failed. This includes the client automatically doing several attempts to reconnect. Always polling to see if the server is up puts unnecessary load on the server and may actually cause the connection to be lost more often if the connection is not 100%, e.g., think wireless.

There is also a callback SWConnection.OnDisconnect that you can take a look at.

We recognize that this is a subject where we are somewhat lacking in functionality so we appreciate your questions and welcome feedback for future development. 

1 Comment

Answer

Here is some helpful information: 


SWConnecion.Instance.GetConnectionsInfo is not relevant to your use case and and should not be used for this.

SWConnection.Instance.Connected does not actually communicate with the server to find out its status. If you pull the cord in your machine, the network card will detect this and will shut down all connections. This is actually not always good. Compare pulling the cord between 2 routers on the way between the client and the server and then putting the cord back. Unless you tried to make a call during the time, the cord was disconnected, the connection will still work.

So by definition, the connection is not considered disconnected until a real call to the server has failed. This includes the client automatically doing several attempts to reconnect. Always polling to see if the server is up puts unnecessary load on the server and may actually cause the connection to be lost more often if the connection is not 100%, e.g., think wireless.

There is also a callback SWConnection.OnDisconnect that you can take a look at.

We recognize that this is a subject where we are somewhat lacking in functionality so we appreciate your questions and welcome feedback for future development. 

Login to post a comment