mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Updated Telepathy to latest version
This commit is contained in:
parent
23acffbe12
commit
437fb06728
@ -7,12 +7,6 @@ namespace Telepathy
|
||||
public abstract class Common
|
||||
{
|
||||
// common code /////////////////////////////////////////////////////////
|
||||
// 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.
|
||||
protected static SafeCounter counter = new SafeCounter();
|
||||
|
||||
// incoming message queue of <connectionId, message>
|
||||
// (not a HashSet because one connection can have multiple new messages)
|
||||
protected SafeQueue<Message> messageQueue = new SafeQueue<Message>();
|
||||
|
@ -15,6 +15,20 @@ public class Server : Common
|
||||
// clients with <connectionId, TcpClient>
|
||||
SafeDictionary<uint, TcpClient> clients = new SafeDictionary<uint, TcpClient>();
|
||||
|
||||
// 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 SafeCounter counter = new SafeCounter();
|
||||
|
||||
// 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 uint NextConnectionId()
|
||||
{
|
||||
return counter.Next();
|
||||
}
|
||||
|
||||
// check if the server is running
|
||||
public bool Active
|
||||
{
|
||||
@ -45,7 +59,7 @@ void Listen(int port)
|
||||
TcpClient client = listener.AcceptTcpClient();
|
||||
|
||||
// generate the next connection id (thread safely)
|
||||
uint connectionId = counter.Next();
|
||||
uint connectionId = NextConnectionId();
|
||||
|
||||
// spawn a thread for each client to listen to his
|
||||
// messages
|
||||
|
Loading…
Reference in New Issue
Block a user