public Agent(string serverAddress, int serverPort) { this.ServerAddress = serverAddress; this.ServerPort = serverPort; this.handler = new MessageDataHandler(this); this.IsRetryConnection = true; this.ConnectRetryRoutine(); }
// Callback for Wireless private void ConnectToWirelessCallback(IAsyncResult result) { if (result.IsCompleted) { try { TcpClient client = (TcpClient)result.AsyncState; client.EndConnect(result); //client. if (client.Connected) { this.stream = this.client.GetStream(); this.BeginRead(this.client); this.handler = new MessageDataHandler(this); // [Auth] this.handler.SendAuthPacket(); this.OnNotifyEvent(this, NotifyEvent.Connected, "已连接"); } } catch (SocketException e) { this.wirelessClient = null; var s = e.Message; } } }