// This will end the client's TCP connection with the server by sending a FIN message, or
 // notify you that the client socket is already disconnected
 public void Disconnect(string args)
 {
     try
     {
         if (client != null)
         {
             SocketErrorCodes err = client.DisconnectFromServer();
             PrintAndLog("Disconnect with error code: " + err);
             client.Dispose();
             client = null;
         }
         else
         {
             CrestronConsole.ConsoleCommandResponse("Client is already disconnected.");
         }
     }
     catch (Exception e)
     {
         PrintAndLog("Error in Disconnect: " + e.Message);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///  Internal call to close up client. ALWAYS use this when disconnecting.
        /// </summary>
        void Cleanup()
        {
            IsTryingToConnect = false;

            if (Client != null)
            {
                //SecureClient.DisconnectFromServer();
                Debug.Console(2, this, "Disconnecting Client {0}", DisconnectCalledByUser ? ", Called by user" : "");
                Client.SocketStatusChange -= Client_SocketStatusChange;
                Client.Dispose();
                Client = null;
            }
            if (ConnectFailTimer != null)
            {
                ConnectFailTimer.Stop();
                ConnectFailTimer.Dispose();
                ConnectFailTimer = null;
            }
        }