Skip to content

Commit

Permalink
fix: fix a typo with NetworkServer disconnection logs, improve commen…
Browse files Browse the repository at this point in the history
…ts, fix formatting (#1005)
  • Loading branch information
SoftwareGuy committed Dec 20, 2021
1 parent 1958173 commit adcf3f6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Assets/Mirage/Runtime/NetworkServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void Stop()

Cleanup();

// remove listen when server is stopped so that
// remove listen when server is stopped so that we can cleanup correctly
Application.quitting -= Stop;
}

Expand Down Expand Up @@ -275,7 +275,7 @@ private void Peer_OnConnected(IConnection conn)
{
var player = new NetworkPlayer(conn);

if (logger.LogEnabled()) logger.Log("Server accepted client:" + player);
if (logger.LogEnabled()) logger.Log($"Server accepted client: {player}");

// add connection
AddConnection(player);
Expand All @@ -286,7 +286,7 @@ private void Peer_OnConnected(IConnection conn)

private void Peer_OnDisconnected(IConnection conn, DisconnectReason reason)
{
if (logger.LogEnabled()) logger.Log($"[{conn}] discconnected with reason {reason}");
if (logger.LogEnabled()) logger.Log($"Client {conn} disconnected with reason: {reason}");

if (connections.TryGetValue(conn, out INetworkPlayer player))
{
Expand All @@ -295,7 +295,7 @@ private void Peer_OnDisconnected(IConnection conn, DisconnectReason reason)
else
{
// todo remove or replace with assert
if (logger.WarnEnabled()) logger.LogWarning($"No handler found for [{conn}]");
if (logger.WarnEnabled()) logger.LogWarning($"No handler found for disconnected client {conn}");
}
}

Expand Down Expand Up @@ -368,16 +368,16 @@ internal void AddLocalConnection(INetworkClient client, IConnection connection)
{
if (LocalPlayer != null)
{
throw new InvalidOperationException("Local Connection already exists");
throw new InvalidOperationException("Local client connection already exists");
}

var player = new NetworkPlayer(connection);
LocalPlayer = player;
LocalClient = client;

if (logger.LogEnabled()) logger.Log("Server accepted Local client:" + player);
if (logger.LogEnabled()) logger.Log($"Server accepted local client connection: {player}");

// add connection
// add the connection for this local player.
AddConnection(player);
}

Expand All @@ -389,7 +389,7 @@ internal void InvokeLocalConnected()
{
if (LocalPlayer == null)
{
throw new InvalidOperationException("Local Connection does not exist");
throw new InvalidOperationException("Local connection does not exist");
}
Connected?.Invoke(LocalPlayer);
}
Expand Down Expand Up @@ -464,7 +464,8 @@ void OnDisconnected(INetworkPlayer player)
{
if (logger.LogEnabled()) logger.Log("Server disconnect client:" + player);

// set flag first so we dont try to send message to connection
// set the flag first so we dont try to send any messages to the disconnected
// connection as they wouldn't get them
player.MarkAsDisconnected();

RemoveConnection(player);
Expand Down Expand Up @@ -508,7 +509,7 @@ public void ReceiveMessage(IConnection connection, ArraySegment<byte> message)
else
{
// todo remove or replace with assert
if (logger.WarnEnabled()) logger.LogWarning($"No player found for [{connection}]");
if (logger.WarnEnabled()) logger.LogWarning($"No player found for message received from client {connection}");
}
}
}
Expand Down

0 comments on commit adcf3f6

Please sign in to comment.