FishNet
FishNet copied to clipboard
I Found an issue in FishNet.Transporting.Tugboat.Server.ServerSocket that need to be fixed right away
I Found a bug in FishNet.Transporting.Tugboat.Server.ServerSocket that need to be fixed right away because it causes the server to halt completely:
private NetPeer GetNetPeer(int connectionId, bool connectedOnly)
{
NetPeer peer = null;
if (_server != null)
{
// There is an or operator here in the original script
and this is a subtle bug that can pass a (-1) value some time.
to reproduce it you need to disconnect the client before the server try to disconnect the same client.
if (connectionId >= 0 && /*was || before*/ _server.ConnectedPeersCount)
peer = _server.GetPeerById(connectionId);
if (connectedOnly && peer != null && peer.ConnectionState != ConnectionState.Connected)
peer = null;
}
return peer;
}
Ah yep, that appears to be a typo. Fortunately I believe this could only be reproduced by manually passing in an invalid Id, so I wouldn't expect it to show up under ordinary usage.
It will be resolved in the next release, 2.5.5. Thanks again!
Just an update to this, this is the new resolution. The change you made will break it for clients reconnecting. Also, _server.GetPeerById checks for -1 values. So you might have something else going on entirely.
private NetPeer GetNetPeer(int connectionId, bool connectedOnly)
{
if (_server != null)
{
NetPeer peer = _server.GetPeerById(connectionId);
if (connectedOnly && peer != null && peer.ConnectionState != ConnectionState.Connected)
peer = null;
return peer;
}
else
{
return null;
}
}