private void ProcessConnectionInvalidCredentials() { var resp = new ServiceMessageResponse { Message = "Invalid user credentials!" }; this.cryptoWrapper.Send(resp.ToBytes()); this.FreeTCPClient(); Log.DebugFormat( "Logon from IP '{0}' failed: Login '{1}'//Password not recognized", this.clientIpAddress, this.Login); }
private void ProcessLogon(ServiceMessage serviceMessage) { // Logon attempt var credentials = LogonCredentials.FromBytes(serviceMessage.Data); if (!this.dataContext.ValidateLoginPass(credentials.Login, credentials.Password)) { this.ProcessConnectionInvalidCredentials(); return; } // Check if user with same login is already logged in if (this.server.IsLoggedIn(credentials.Login)) { var existingClient = this.server.GetChatClient(credentials.Login); if (existingClient.PokeForAlive()) { // Client with login <login> still alive -> new login attempt invalid var resp = new ServiceMessageResponse { Message = "This login is already used" }; this.cryptoWrapper.Send(resp.ToBytes()); this.FreeTCPClient(); Log.DebugFormat( "Logon from IP '{0}' failed: User '{1}' already logged on", this.clientIpAddress, credentials.Login); } else { // Old client app which used current login is unresponsive -> dispose of it and add new this.server.RemoveClient(credentials.Login); Log.DebugFormat( "Old client app which used login '{0}' is unresponsive -> dispose of it and add new", credentials.Login); this.server.AddLoggedInUser(credentials.Login, this); } } else { this.server.AddLoggedInUser(credentials.Login, this); this.cryptoWrapper.Send(ServiceMessageResponse.Success.ToBytes()); Log.DebugFormat( "Logon from IP '{0}' success: User '{1}' from IP logged on", this.clientIpAddress, credentials.Login); } this.Login = credentials.Login; }
private void ProcessLogon(ServiceMessage serviceMessage) { // Logon attempt var credentials = LogonCredentials.FromBytes(serviceMessage.Data); if (!this.dataContext.ValidateLoginPass(credentials.Login, credentials.Password)) { this.ProcessConnectionInvalidCredentials(); return; } // Check if user with same login is already logged in if (this.server.IsLoggedIn(credentials.Login)) { var existingClient = this.server.GetChatClient(credentials.Login); if (existingClient.PokeForAlive()) { // Client with login <login> still alive -> new login attempt invalid var resp = new ServiceMessageResponse { Message = "This login is already used"}; this.cryptoWrapper.Send(resp.ToBytes()); this.FreeTCPClient(); Log.DebugFormat( "Logon from IP '{0}' failed: User '{1}' already logged on", this.clientIpAddress, credentials.Login); } else { // Old client app which used current login is unresponsive -> dispose of it and add new this.server.RemoveClient(credentials.Login); Log.DebugFormat( "Old client app which used login '{0}' is unresponsive -> dispose of it and add new", credentials.Login); this.server.AddLoggedInUser(credentials.Login, this); } } else { this.server.AddLoggedInUser(credentials.Login, this); this.cryptoWrapper.Send(ServiceMessageResponse.Success.ToBytes()); Log.DebugFormat( "Logon from IP '{0}' success: User '{1}' from IP logged on", this.clientIpAddress, credentials.Login); } this.Login = credentials.Login; }
private void ProcessConnectionInvalidCredentials() { var resp = new ServiceMessageResponse { Message = "Invalid user credentials!" }; this.cryptoWrapper.Send(resp.ToBytes()); this.FreeTCPClient(); Log.DebugFormat( "Logon from IP '{0}' failed: Login '{1}'//Password not recognized", this.clientIpAddress, this.Login); }