示例#1
0
        /// <summary>
        /// Stops server.
        /// </summary>
        public override void Stop()
        {
            if (!IsStarted)
            {
                return;
            }

            _listener.Stop();
            if (_acceptThread != null && _acceptThread.IsAlive)
            {
                _acceptThread.Interrupt();
                _acceptThread.Join();
            }

            IsStarted = false;
            while (SocketClients.Count > 0)
            {
                SocketClientBase socketClient = SocketClients[0];
                socketClient.Disconnect();
                if (SocketClients.Contains(socketClient))
                {
                    SocketClients.Remove(socketClient);
                }
            }
        }
示例#2
0
        private void SocketClientDisconnected(object sender, SocketEventArgs e)
        {
            var socketClient = sender as SocketClientBase;

            if (socketClient != null && SocketClients.Contains(socketClient))
            {
                SocketClients.Remove(socketClient);
            }
            OnDisconnected(e);
        }
 /// <summary>
 /// Stops server.
 /// </summary>
 public override void Stop()
 {
     if (ServerStatus == SocketServerStatus.Stop)
     {
         return;
     }
     ServerStatus = SocketServerStatus.Stop;
     _listener.Stop();
     while (SocketClients.Count > 0)
     {
         var socketClient = SocketClients[0];
         socketClient.Disconnect();
         if (SocketClients.Contains(socketClient))
         {
             SocketClients.Remove(socketClient);
         }
     }
 }