private void RemoveAuthenticatedClient(AuthenticatedTcpClient authenticatedTcpClient) { try { if (allAuthenticatedClients.Contains(authenticatedTcpClient)) { allAuthenticatedClients.Remove(authenticatedTcpClient); } } catch { } }
private void AddAuthenticatedClient(CommunicationMessage receivedCommunicationMessage, TcpClient clientThatConnected) { if (receivedCommunicationMessage.MessageType == (int)Common.CommunicationMessageType.Login) { Common.CommunicationAuthenticationData communicationAuthenticationData; communicationAuthenticationData.ID = receivedCommunicationMessage.SenderID; communicationAuthenticationData.Authentication = receivedCommunicationMessage.SenderAuthentication; communicationAuthenticationData.Type = (Common.CommunicationClientType)receivedCommunicationMessage.SenderType; AuthenticatedTcpClient authenticatedTcpClient = new AuthenticatedTcpClient(communicationAuthenticationData); if (authenticatedTcpClient.IsAuthenticated()) { allConnectedClients.Remove(clientThatConnected); authenticatedTcpClient.tcpClient = clientThatConnected; allAuthenticatedClients.Add(authenticatedTcpClient); } } }