OnStateChangeAction vs. OnStatusChanged

JohnTube
✭✭✭✭✭
If I want to update the UI according to the connection state which callback should use : OnStateChangeAction or OnStatusChanged (StatusCode vs. ClientState) ?
0
Comments
-
It depends on which state you need. The OnStatusChanged() is a lower-level (network-related) state. The OnStateChangeAction is higher (game) level related.
Take a look at the enum of the possible values. It should be clear then.0 -
In the LoadBalancingClient there is a property IsConnectedAndReady :
/// <summary> /// A refined version of connected which is true only if your connection to the server is ready to accept operations like join, leave, etc. /// </summary> public bool IsConnectedAndReady { get { if (this.loadBalancingPeer == null) { return false; } switch (this.State) { case ClientState.Uninitialized: case ClientState.Disconnected: case ClientState.Disconnecting: case ClientState.Authenticating: case ClientState.ConnectingToGameserver: case ClientState.ConnectingToMasterserver: case ClientState.ConnectingToNameServer: case ClientState.Joining: case ClientState.Leaving: return false; // we are not ready to execute any operations } return true; } }
The problem is that if I connect to the NameServer only IsConnectedAndReady will return true which means I can execute create/join operations which is wrong as those operations can only executed from MasterServer or GameServer. Am I wrong ?0 -
You are correct. This might be a bit misleading.
IsConnectedAndReady tells you if operations can be sent currently. It does not tell you which server you are on and which operations are possible.
E.g. the NameServer has an operation GetRegions but pretty much nothing else, the master does not allow you to OpRaiseEvent and on the game server you can't use OpJoinLobby.
You have to check which server you are on, which is stored in LoadBalancingClient.Server.
I will check if I can make the doc more useful.0