コード例 #1
0
ファイル: SocketServer.cs プロジェクト: morz/OETS.Journal
        /// <summary>
        /// Remove the client from the server's list of clients.
        /// Events: ClientDisconnected
        /// </summary>
        private void OnClientManagerClientDisconnected(object sender, TimedEventArgs ea)
        {
            ClientManager cm = sender as ClientManager;
            if (cm == null)
                return;

            ClientKey clientKey = new ClientKey(cm.IPAddress, cm.Port);

            lock (clients.SyncRoot)
            {
                if (clients.Contains(clientKey))
                    clients.Remove(clientKey);

                if (ClientDisconnected != null)
                    ClientDisconnected(this, new ClientEventArgs(cm));

               }
        }
コード例 #2
0
ファイル: SocketServer.cs プロジェクト: morz/OETS.Journal
        /// <summary>
        /// Disconnects a ClientManager and removes it from the list of clients.
        /// </summary>
        private void DisconnectClientManager(ClientManager cm)
        {
            ClientKey clientKey = new ClientKey(cm.IPAddress, cm.Port);

            lock (clients.SyncRoot)
            {
                cm.Disconnect();

                if (clients.Contains(clientKey))
                    clients.Remove(clientKey);
            }
        }
コード例 #3
0
ファイル: SocketServer.cs プロジェクト: morz/OETS.Journal
 /// <summary>
 /// Returns the ClientManager object associated with the clientKey.
 /// The communication between the server and the client is handled 
 /// by a ClientManager object identified by a ClientKey.
 /// </summary>
 public ClientManager this[ClientKey clientKey]
 {
     get { return (ClientManager)clients[clientKey]; }
 }