public static void AddNewClient(TcpClientIdentifier clientID, TcpClient tcpClient) { Client client = new Client(clientID, tcpClient); rwLock.EnterWriteLock(); try { clients.Add(clientID, client); } finally { rwLock.ExitWriteLock(); } }
public Client(TcpClientIdentifier tcpID, Tcp.TcpClient tcpClient) { this.tcpID = tcpID; this.tcpClient = tcpClient; this.tcpClient.CustomHeaderSize = GetCustomPacketHeaderSize(); this.packetModifiers = new PacketModifiers(); //database = new MySql("localhost", 3306, "test", "root", "test"); #if EVENTTHREAD eventThread = new PlayerEventThread(this); #endif AddEventHandlers(); SetupPacketSecurity(); }
public static Client GetClient(TcpClientIdentifier clientID) { rwLock.EnterReadLock(); try { Client client; if (clients.TryGetValue(clientID, out client)) { return(client); } else { return(null); } } finally { rwLock.ExitReadLock(); } }
/// <summary> /// Adds a player to the index list /// </summary> /// <param name="playerID">The id of the player to add</param> /// <param name="tcpID">The id of the tcp client to add</param> public static void AddPlayerToIndexList(string playerID, TcpClientIdentifier tcpID) { rwLock.EnterUpgradeableReadLock(); try { int index = playerIDToTcpIDList.IndexOfKey(playerID); if (index == -1) { rwLock.EnterWriteLock(); try { playerIDToTcpIDList.Add(playerID, tcpID); } finally { rwLock.ExitWriteLock(); } } } finally { rwLock.ExitUpgradeableReadLock(); } }
/// <summary> /// Removes a player from the index list based on the players index /// </summary> /// <param name="index">The index of the player to remove</param> public static void RemovePlayerFromIndexList(TcpClientIdentifier tcpID) { rwLock.EnterWriteLock(); try { int index = playerIDToTcpIDList.IndexOfValue(tcpID); if (index > -1) { playerIDToTcpIDList.RemoveAt(index); } } finally { rwLock.ExitWriteLock(); } }
public static Client GetClient(TcpClientIdentifier clientID) { rwLock.EnterReadLock(); try { Client client; if (clients.TryGetValue(clientID, out client)) { return client; } else { return null; } } finally { rwLock.ExitReadLock(); } }
public static TcpClient GetTcpClient(TcpClientIdentifier clientID) { return(tcpListener.ClientCollection.GetTcpClient(clientID)); }
public static TcpClient GetTcpClient(TcpClientIdentifier clientID) { return tcpListener.ClientCollection.GetTcpClient(clientID); }