Пример #1
0
 public static void Disconnect()
 {
     if (client != null ) {
         client.Disconnect();
         client = null;
     }
 }
Пример #2
0
 public static void Connect(string host, ushort port, bool isRetry = false)
 {
     if (shuttingDown)
         return;
     if (!isRetry)
         ConnectionStatusChanged(ConnectionStatus.Connecting);
     client = new BytesEventTcpClient();
     client.OnConnect += new EventTcpClient.OnConnectEventHandler(client_OnConnect);
     client.OnDataReceived += new BytesEventTcpClient.BytesReceivedEventHandler(client_OnDataReceived);
     client.OnDisconnect += new EventTcpClient.OnDisconnectEventHandler(client_OnDisconnect);
     client.OnRefused += new EventTcpClient.OnRefusedEventHandler(client_OnRefused);
     lastHost = host;
     lastPort = port;
     client.Connect(host, port);
 }