diff --git a/Assets/Mirror/Transports/Telepathy/Telepathy/Client.cs b/Assets/Mirror/Transports/Telepathy/Telepathy/Client.cs index 44fa0b576..b2a1c85b1 100644 --- a/Assets/Mirror/Transports/Telepathy/Telepathy/Client.cs +++ b/Assets/Mirror/Transports/Telepathy/Telepathy/Client.cs @@ -153,7 +153,7 @@ static void ReceiveThreadFunction(ClientConnectionState state, string ip, int po { // this happens if (for example) the ip address is correct // but there is no server running on that ip/port - Log.Info("[Telepathy] Client Recv: failed to connect to ip=" + ip + " port=" + port + " reason=" + exception); + Log.Info("Client Recv: failed to connect to ip=" + ip + " port=" + port + " reason=" + exception); } catch (ThreadInterruptedException) { @@ -171,7 +171,7 @@ static void ReceiveThreadFunction(ClientConnectionState state, string ip, int po catch (Exception exception) { // something went wrong. probably important. - Log.Error("[Telepathy] Client Recv Exception: " + exception); + Log.Error("Client Recv Exception: " + exception); } // add 'Disconnected' event to receive pipe so that the caller // knows that the Connect failed. otherwise they will never know @@ -200,7 +200,7 @@ public void Connect(string ip, int port) // not if already started if (Connecting || Connected) { - Log.Warning("[Telepathy] Client can not create connection because an existing connection is connecting or connected"); + Log.Warning("Telepathy Client can not create connection because an existing connection is connecting or connected"); return; } @@ -287,17 +287,17 @@ public bool Send(ArraySegment message) else { // log the reason - Log.Warning($"[Telepathy] Client.Send: sendPipe reached limit of {SendQueueLimit}. This can happen if we call send faster than the network can process messages. Disconnecting to avoid ever growing memory & latency."); + Log.Warning($"Client.Send: sendPipe reached limit of {SendQueueLimit}. This can happen if we call send faster than the network can process messages. Disconnecting to avoid ever growing memory & latency."); // just close it. send thread will take care of the rest. state.client.Close(); return false; } } - Log.Error("[Telepathy] Client.Send: message too big: " + message.Count + ". Limit: " + MaxMessageSize); + Log.Error("Client.Send: message too big: " + message.Count + ". Limit: " + MaxMessageSize); return false; } - Log.Warning("[Telepathy] Client.Send: not connected!"); + Log.Warning("Client.Send: not connected!"); return false; } diff --git a/Assets/Mirror/Transports/Telepathy/Telepathy/Server.cs b/Assets/Mirror/Transports/Telepathy/Telepathy/Server.cs index 687b90e5c..0b4ada7e7 100644 --- a/Assets/Mirror/Transports/Telepathy/Telepathy/Server.cs +++ b/Assets/Mirror/Transports/Telepathy/Telepathy/Server.cs @@ -95,7 +95,7 @@ void Listen(int port) //listener.Server.SendTimeout = SendTimeout; //listener.Server.ReceiveTimeout = ReceiveTimeout; listener.Start(); - Log.Info($"[Telepathy] Starting server on port {port}"); + Log.Info("Server: listening port=" + port); // keep accepting new clients while (true) @@ -138,7 +138,7 @@ void Listen(int port) } catch (Exception exception) { - Log.Error("[Telepathy] Server send thread exception: " + exception); + Log.Error("Server send thread exception: " + exception); } }); sendThread.IsBackground = true; @@ -172,7 +172,7 @@ void Listen(int port) } catch (Exception exception) { - Log.Error("[Telepathy] Server client thread exception: " + exception); + Log.Error("Server client thread exception: " + exception); } }); receiveThread.IsBackground = true; @@ -183,18 +183,18 @@ void Listen(int port) { // UnityEditor causes AbortException if thread is still // running when we press Play again next time. that's okay. - Log.Info("[Telepathy] Server thread aborted. That's okay. " + exception); + Log.Info("Server thread aborted. That's okay. " + exception); } catch (SocketException exception) { // calling StopServer will interrupt this thread with a // 'SocketException: interrupted'. that's okay. - Log.Info("[Telepathy] Server Thread stopped. That's okay. " + exception); + Log.Info("Server Thread stopped. That's okay. " + exception); } catch (Exception exception) { // something went wrong. probably important. - Log.Error("[Telepathy] Server Exception: " + exception); + Log.Error("Server Exception: " + exception); } } @@ -215,8 +215,7 @@ public bool Start(int port) // start the listener thread // (on low priority. if main thread is too busy then there is not // much value in accepting even more clients) - Log.Info($"[Telepathy] Starting server on port {port}"); - + Log.Info("Server: Start port=" + port); listenerThread = new Thread(() => { Listen(port); }); listenerThread.IsBackground = true; listenerThread.Priority = ThreadPriority.BelowNormal; @@ -229,7 +228,7 @@ public void Stop() // only if started if (!Active) return; - Log.Info("[Telepathy] Server: stopping..."); + Log.Info("Server: stopping..."); // stop listening to connections so that no one can connect while we // close the client connections @@ -296,7 +295,7 @@ public bool Send(int connectionId, ArraySegment message) else { // log the reason - Log.Warning($"[Telepathy] Server.Send: sendPipe for connection {connectionId} reached limit of {SendQueueLimit}. This can happen if we call send faster than the network can process messages. Disconnecting this connection for load balancing."); + Log.Warning($"Server.Send: sendPipe for connection {connectionId} reached limit of {SendQueueLimit}. This can happen if we call send faster than the network can process messages. Disconnecting this connection for load balancing."); // just close it. send thread will take care of the rest. connection.client.Close(); @@ -312,7 +311,7 @@ public bool Send(int connectionId, ArraySegment message) //Logger.Log("Server.Send: invalid connectionId: " + connectionId); return false; } - Log.Error("[Telepathy] Server.Send: message too big: " + message.Count + ". Limit: " + MaxMessageSize); + Log.Error("Server.Send: message too big: " + message.Count + ". Limit: " + MaxMessageSize); return false; } @@ -335,7 +334,7 @@ public bool Disconnect(int connectionId) { // just close it. send thread will take care of the rest. connection.client.Close(); - Log.Info("[Telepathy] Server.Disconnect connectionId:" + connectionId); + Log.Info("Server.Disconnect connectionId:" + connectionId); return true; } return false; diff --git a/Assets/Mirror/Transports/Telepathy/Telepathy/ThreadFunctions.cs b/Assets/Mirror/Transports/Telepathy/Telepathy/ThreadFunctions.cs index a5f032426..6f026c99b 100644 --- a/Assets/Mirror/Transports/Telepathy/Telepathy/ThreadFunctions.cs +++ b/Assets/Mirror/Transports/Telepathy/Telepathy/ThreadFunctions.cs @@ -34,7 +34,7 @@ public static bool SendMessagesBlocking(NetworkStream stream, byte[] payload, in catch (Exception exception) { // log as regular message because servers do shut down sometimes - Log.Info("[Telepathy] Send: stream.Write exception: " + exception); + Log.Info("Send: stream.Write exception: " + exception); return false; } } @@ -47,7 +47,7 @@ public static bool ReadMessageBlocking(NetworkStream stream, int MaxMessageSize, // buffer needs to be of Header + MaxMessageSize if (payloadBuffer.Length != 4 + MaxMessageSize) { - Log.Error($"[Telepathy] ReadMessageBlocking: payloadBuffer needs to be of size 4 + MaxMessageSize = {4 + MaxMessageSize} instead of {payloadBuffer.Length}"); + Log.Error($"ReadMessageBlocking: payloadBuffer needs to be of size 4 + MaxMessageSize = {4 + MaxMessageSize} instead of {payloadBuffer.Length}"); return false; } @@ -68,7 +68,7 @@ public static bool ReadMessageBlocking(NetworkStream stream, int MaxMessageSize, // read exactly 'size' bytes for content (blocking) return stream.ReadExactly(payloadBuffer, size); } - Log.Warning("[Telepathy] ReadMessageBlocking: possible header attack with a header of: " + size + " bytes."); + Log.Warning("ReadMessageBlocking: possible header attack with a header of: " + size + " bytes."); return false; } @@ -139,7 +139,7 @@ public static void ReceiveLoop(int connectionId, TcpClient client, int MaxMessag if (receivePipe.Count(connectionId) >= QueueLimit) { // log the reason - Log.Warning($"[Telepathy] ReceivePipe reached limit of {QueueLimit} for connectionId {connectionId}. This can happen if network messages come in way faster than we manage to process them. Disconnecting this connection for load balancing."); + Log.Warning($"receivePipe reached limit of {QueueLimit} for connectionId {connectionId}. This can happen if network messages come in way faster than we manage to process them. Disconnecting this connection for load balancing."); // IMPORTANT: do NOT clear the whole queue. we use one // queue for all connections. @@ -155,7 +155,7 @@ public static void ReceiveLoop(int connectionId, TcpClient client, int MaxMessag // something went wrong. the thread was interrupted or the // connection closed or we closed our own connection or ... // -> either way we should stop gracefully - Log.Info("[Telepathy] ReceiveLoop finished receive function for connectionId=" + connectionId + " reason: " + exception); + Log.Info("ReceiveLoop: finished receive function for connectionId=" + connectionId + " reason: " + exception); } finally { @@ -226,7 +226,7 @@ public static void SendLoop(int connectionId, TcpClient client, MagnificentSendP // something went wrong. the thread was interrupted or the // connection closed or we closed our own connection or ... // -> either way we should stop gracefully - Log.Info("[Telepathy] SendLoop Exception: connectionId=" + connectionId + " reason: " + exception); + Log.Info("SendLoop Exception: connectionId=" + connectionId + " reason: " + exception); } finally { diff --git a/Assets/Mirror/Transports/Telepathy/Telepathy/VERSION b/Assets/Mirror/Transports/Telepathy/Telepathy/VERSION index 9ec073658..a0e7ded5d 100644 --- a/Assets/Mirror/Transports/Telepathy/Telepathy/VERSION +++ b/Assets/Mirror/Transports/Telepathy/Telepathy/VERSION @@ -1,3 +1,6 @@ +V1.9 [2023-11-10] +- fix: Always enqueue Disconnected event (imer) + V1.8 [2021-06-02] - fix: Do not set timeouts on listener (fixes https://github.com/vis2k/Mirror/issues/2695) - fix: #104 - ReadSafely now catches ObjectDisposedException too