private void Listen() { new Thread( async() => { while (_listening) { while (_tcpClient.Available <= 0) { Thread.Sleep(100); } var messageProtocol = await MessageCommunicator.ReadAsync(_tcpClient); await _protocolProcessor.ProcessAsync(messageProtocol); } }).Start(); }
private async Task <IClient> GetMeseClientInformation(TcpClient client) { MeseClient meseClient = null; WaitForClient(client); var messageProtocol = await MessageCommunicator.ReadAsync(client); var name = messageProtocol.GetDataAs <string>(); if (!string.IsNullOrEmpty(name)) { meseClient = new MeseClient(client, name); } return(meseClient); }
public async Task StartListeningAsync() { while (true) { try { var messageProtocol = await MessageCommunicator.ReadAsync(_meseClient.TcpClient); MessageProtocolReceived?.Invoke(this, new MessageProtocolReceivedEventArgs(messageProtocol)); } catch (IOException exception) { ThrowDisconnectException(exception); } catch (SocketException exception) { ThrowDisconnectException(exception); } } }