public static void AddNewClient(TcpClientIdentifier clientID, TcpClient tcpClient)
        {
            Client client = new Client(clientID, tcpClient);

            rwLock.EnterWriteLock();
            try {
                clients.Add(clientID, client);
            } finally {
                rwLock.ExitWriteLock();
            }
        }
Beispiel #2
0
        public static void AddNewClient(TcpClientIdentifier clientID, TcpClient tcpClient)
        {
            Client client = new Client(clientID, tcpClient);

            rwLock.EnterWriteLock();
            try {
                clients.Add(clientID, client);
            } finally {
                rwLock.ExitWriteLock();
            }
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        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();
            }
        }
Beispiel #6
0
        /// <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();
            }
        }
Beispiel #7
0
 /// <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();
     }
 }
Beispiel #8
0
        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();
            }
        }
Beispiel #9
0
 public static TcpClient GetTcpClient(TcpClientIdentifier clientID)
 {
     return(tcpListener.ClientCollection.GetTcpClient(clientID));
 }
Beispiel #10
0
 public static TcpClient GetTcpClient(TcpClientIdentifier clientID)
 {
     return tcpListener.ClientCollection.GetTcpClient(clientID);
 }