コード例 #1
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();
            }
        }
コード例 #2
0
ファイル: ClientManager.cs プロジェクト: pzaps/Server
        public static void AddNewClient(TcpClientIdentifier clientID, TcpClient tcpClient)
        {
            Client client = new Client(clientID, tcpClient);

            rwLock.EnterWriteLock();
            try {
                clients.Add(clientID, client);
            } finally {
                rwLock.ExitWriteLock();
            }
        }
コード例 #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();
        }
コード例 #4
0
ファイル: Client.cs プロジェクト: ScruffyKnight/PMU-Server
        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();
        }
コード例 #5
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();
            }
        }
コード例 #6
0
ファイル: PlayerID.cs プロジェクト: pzaps/Server
        /// <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();
            }
        }
コード例 #7
0
ファイル: PlayerID.cs プロジェクト: pzaps/Server
 /// <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();
     }
 }
コード例 #8
0
ファイル: ClientManager.cs プロジェクト: pzaps/Server
        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();
            }
        }
コード例 #9
0
ファイル: NetworkManager.cs プロジェクト: SupaFresh/Server
 public static TcpClient GetTcpClient(TcpClientIdentifier clientID)
 {
     return(tcpListener.ClientCollection.GetTcpClient(clientID));
 }
コード例 #10
0
ファイル: NetworkManager.cs プロジェクト: pzaps/Server
 public static TcpClient GetTcpClient(TcpClientIdentifier clientID)
 {
     return tcpListener.ClientCollection.GetTcpClient(clientID);
 }