Skip to content

Commit

Permalink
Fix socket disconnect creating a new connection object
Browse files Browse the repository at this point in the history
  • Loading branch information
Reousa committed Jan 13, 2024
1 parent a5ff5c7 commit b6c4151
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions NebulaNetwork/Messaging/WebSocketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ protected override void OnMessage(MessageEventArgs e)

protected override void OnClose(CloseEventArgs e)
{
connections.Remove(Context.UserEndPoint.GetHashCode());

var connection = connections[Context.UserEndPoint.GetHashCode()];
connections.Remove(connection.GetHashCode());
// If the reason of a client disconnect is because we are still loading the game,
// we don't need to inform the other clients since the disconnected client never
// joined the game in the first place.
Expand All @@ -74,8 +74,7 @@ protected override void OnClose(CloseEventArgs e)
// if it is because we have stopped the server and are not in a multiplayer game anymore.
if (Multiplayer.IsActive)
{
Server.OnSocketDisconnection(new NebulaConnection(Context.WebSocket, Context.UserEndPoint,
PacketProcessor));
Server.OnSocketDisconnection(connection);
}
});
}
Expand Down

0 comments on commit b6c4151

Please sign in to comment.