public override void Handle(LoginRequest request) { if (!IsRequestValid(request.SessionId)) { return; } if (SessionRepository.IsUserLoggedIn(request.UserId)) { var sessionInfo = SessionRepository.GetSessionForUser(request.UserId); if (sessionInfo != null && sessionInfo.SessionId != request.SessionId) { const string errorMsg = "the user is already logged in"; Socket.SendNetworkMsg(new ErrorResponse(errorMsg)); return; } } var user = dataCenter.GetUser(request.UserId); if (user.Password != request.Password) { const string errorMsg = "the password is incorrect"; Socket.SendNetworkMsg(new ErrorResponse(errorMsg)); return; } SessionRepository.UpdateLoggedInUser(request.SessionId, user); Socket.SendNetworkMsg(new LoginResponse()); }