diff --git a/Assets/Mirror/Runtime/Transport/Telepathy/SafeQueue.cs b/Assets/Mirror/Runtime/Transport/Telepathy/SafeQueue.cs index 59a32bfff..9ebdf8a51 100644 --- a/Assets/Mirror/Runtime/Transport/Telepathy/SafeQueue.cs +++ b/Assets/Mirror/Runtime/Transport/Telepathy/SafeQueue.cs @@ -13,7 +13,7 @@ namespace Telepathy { public class SafeQueue { - Queue queue = new Queue(); + readonly Queue queue = new Queue(); // for statistics. don't call Count and assume that it's the same after the // call. @@ -42,7 +42,7 @@ public bool TryDequeue(out T result) { lock(queue) { - result = default(T); + result = default; if (queue.Count > 0) { result = queue.Dequeue(); diff --git a/Assets/Mirror/Runtime/Transport/Telepathy/Server.cs b/Assets/Mirror/Runtime/Transport/Telepathy/Server.cs index 36c242617..e8b4aa0ae 100644 --- a/Assets/Mirror/Runtime/Transport/Telepathy/Server.cs +++ b/Assets/Mirror/Runtime/Transport/Telepathy/Server.cs @@ -34,19 +34,17 @@ public ClientToken(TcpClient client) this.client = client; } } + // clients with - ConcurrentDictionary clients = new ConcurrentDictionary(); + readonly ConcurrentDictionary clients = new ConcurrentDictionary(); // connectionId counter - // (right now we only use it from one listener thread, but we might have - // multiple threads later in case of WebSockets etc.) - // -> static so that another server instance doesn't start at 0 again. - static int counter = 0; + int counter; // public next id function in case someone needs to reserve an id // (e.g. if hostMode should always have 0 connection and external // connections should start at 1, etc.) - public static int NextConnectionId() + public int NextConnectionId() { int id = Interlocked.Increment(ref counter);