/// <summary> /// Handle client. /// </summary> /// <param name="client">Connected client.</param> private async Task HandleClient(MpClient client) { log.Info($"Client connected. ip {((IPEndPoint)client.tcpClient.Client.RemoteEndPoint).Address.ToString()}"); await Task.Run(() => { try { // recieve client's message Message message = client.ReceiveMessage(); // login / register if (message != null) { if (message is LoginRequestMessage) { LoginClient(client, (LoginRequestMessage)message); } else if (message is RegisterRequestMessage) { RegisterClient(client, (RegisterRequestMessage)message); } } } catch (ConnectionInterruptedException e) { log.Error("Connection with client brokes.", e); } }); }