Average (most often used) server behavior: if the user is logged in from another device - server disconnects his previous connection.
Alas, this is not implemented in LoadBalancing. At the forum, many asked a question about it.
I suggest to get acquainted with my solution to this problem. Perhaps it is useful to someone.
Or maybe someone advise how it can be improved.
Decision:
The basis I took a mechanic PlayerCache.
In PlayerState class added the following members
In functions OnConnectedToMaster and HandleOnConnectedToMaster add parameter - peer.
Now OnConnectedToMaster looks like this:
In function HandleOnConnectedToMaster add code:
And in function HandleOnDisconnectFromMaster add code:
Done.
Important: This solution only for MasterServer.
For users connected to GameServer it does not work.
Now I think over the decision to GameServer. When it will be ready - I'll post it.
Alas, this is not implemented in LoadBalancing. At the forum, many asked a question about it.
I suggest to get acquainted with my solution to this problem. Perhaps it is useful to someone.
Or maybe someone advise how it can be improved.
Decision:
The basis I took a mechanic PlayerCache.
In PlayerState class added the following members
public bool IsDisconnectedDuplicate { get; set; } // sign that disconnects carried out due to re-entering user
public MasterClientPeer Peer { get; set; } // actual peer this user
In functions OnConnectedToMaster and HandleOnConnectedToMaster add parameter - peer.
Now OnConnectedToMaster looks like this:
public void OnConnectedToMaster(string playerId, MasterClientPeer peer)
{
this.fiber.Enqueue(() => this.HandleOnConnectedToMaster(playerId, peer));
}
In function HandleOnConnectedToMaster add code:
if (this.playerDict.TryGetValue(playerId, out playerState) == false)
{
playerState = new PlayerState(playerId);
playerState.Peer = peer; // my hack
this.playerDict.Add(playerId, playerState);
}
// start my hack
else
{
playerState.Peer.Disconnect();
playerState.IsDisconnectedDuplicate = true;
playerState.Peer = peer;
}
// end my hack
And in function HandleOnDisconnectFromMaster add code:
if (this.playerDict.TryGetValue(playerId, out playerState) == false)
{
return;
}
// start my hack
if (playerState.IsDisconnectedDuplicate)
{
playerState.IsDisconnectedDuplicate = false;
return;
}
// end my hack
Done.
Important: This solution only for MasterServer.
For users connected to GameServer it does not work.
Now I think over the decision to GameServer. When it will be ready - I'll post it.