コード例 #1
0
 internal void ClientDisconnect(ClientContainer client)
 {
     if (client != null)
     {
         lock (syncObjectClients) _clients.Remove(client);
         var socket = client.socket;
         if (socket != null)
         {
             LingerOption lingerOption = new LingerOption(true, 1);
             socket.LingerState = lingerOption;
             try
             {
                 if (socket.Connected)
                 {
                     socket.Shutdown(SocketShutdown.Both);
                     socket.Close();
                 }
             }
             catch (Exception ex)
             {
                 if (_showFail)
                 {
                     Debug.Fail(ex.Message, ex.StackTrace);
                 }
             }
         }
         if (client.ClientId > 0)
         {
             CallClientDisconnect(client.ClientId);
         }
         client.Dispose();
     }
 }
コード例 #2
0
        public void Disconnect(CloseReason reason = CloseReason.ClientClosed)
        {
            ClientContainer.Shutdown(reason);

            Address = "";
            Port    = 0;
            KeySize = 0;

            ClientContainer.Dispose();
            ClientContainer = null;
        }