public static void Disconnect() { if (client != null ) { client.Disconnect(); client = null; } }
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); }