mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
fix: Telepathy updated to latest version. connectionId counter is properly reset after stopping server.
This commit is contained in:
parent
c80fe05d50
commit
abf06df25d
@ -13,7 +13,7 @@ namespace Telepathy
|
||||
{
|
||||
public class SafeQueue<T>
|
||||
{
|
||||
Queue<T> queue = new Queue<T>();
|
||||
readonly Queue<T> queue = new Queue<T>();
|
||||
|
||||
// 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();
|
||||
|
@ -34,19 +34,17 @@ public ClientToken(TcpClient client)
|
||||
this.client = client;
|
||||
}
|
||||
}
|
||||
|
||||
// clients with <connectionId, ClientData>
|
||||
ConcurrentDictionary<int, ClientToken> clients = new ConcurrentDictionary<int, ClientToken>();
|
||||
readonly ConcurrentDictionary<int, ClientToken> clients = new ConcurrentDictionary<int, ClientToken>();
|
||||
|
||||
// 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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user