public NetworkClient(string serverAddr, int serverPort) { this.serverAddr = serverAddr; this.serverPort = serverPort; tcpClient = null; data = null; //StateChangedEvent = null; //DataReceivedEvent = null; //DataSendedEvent = null; canReceiveNewData = true; SetState(NetworkClientState.None); }
private void ConnectToServerCallback(IAsyncResult ar) { try { //tcpClient = (TcpClient)ar.AsyncState; tcpClient.EndConnect(ar); data = new NetworkData(); Debug.Log("NetworkClient - Connected!"); SetState(NetworkClientState.Connected); Receive(); } catch (Exception e) { Debug.LogWarning("NetworkClient - " + e.Message); SetState(NetworkClientState.Error); } }