private void ProcessClient(NetworkClient networkClient) { if (networkClient.IsOnline) { return; } var clientOnServer = ClientsOnServer.FirstOrDefault( x => x.TcpClient.Client.RemoteEndPoint.Equals(networkClient.Adress)); RemoveClient(clientOnServer); }
private void ProcessTextMessage(NetworkMessage message, TcpClient client) { var clientOnServer = ClientsOnServer.FirstOrDefault( x => Equals(x.TcpClient.Client.RemoteEndPoint, message.FromPoint)); if (clientOnServer != null) { clientOnServer.LastActivityTime = DateTime.Now; SaveMessageToLogFile(message, clientOnServer.Name); } var isDelivered = SendMessage(message); //отправка информации о состоянии сообщения client.PutDataToStream(new NetworkMessageState(isDelivered)); }
private bool SendMessage(NetworkMessage message) { try { var netClient = ClientsOnServer.FirstOrDefault(x => Equals(x.TcpClient.Client.RemoteEndPoint, message.ToPoint)); if (netClient != null) { netClient.TcpClient.PutDataToStream(message); return(true); } return(false); } catch (Exception) { return(false); } }