public async Task <MatchRequestResult> RequestMatch(ActiveUser activeUser, string oppoId) { var dUser = await _masterRepo.GetUserByIdAsyc(activeUser.Id); if (dUser.Money < Room.MinBet) { throw new BadUserInputException(); } //BadUserInputException is thrown when something is wrong but should've been //validated by the client var oppoUser = await _masterRepo.GetUserByIdAsyc(oppoId); var friendship = _masterRepo.GetFriendship(activeUser.Id, oppoId); if (friendship is FriendShip.None or FriendShip.Follower && !oppoUser.EnableOpenMatches) { throw new BadUserInputException(); } if (!_sessionRepo.IsUserActive(oppoId)) { return(MatchRequestResult.Offline); } if (_sessionRepo.DoesRoomUserExist(oppoId)) { return(MatchRequestResult.Playing); } if (oppoUser.Money < Room.MinBet) { return(MatchRequestResult.NoMoney); } //can't call again because this fun domain is lobby.idle only activeUser.Domain = typeof(UserDomain.App.Lobby.Pending); activeUser.ChallengeRequestTarget = oppoId; var oppoAU = _sessionRepo.GetActiveUser(oppoId); //oppo is 100% active at this satage await _masterHub.SendOrderedAsync(oppoAU, "ChallengeRequest", Mapper.UserToMinUserInfoFunc(dUser)); return(MatchRequestResult.Available); }
public override async Task OnConnectedAsync() { _logger.LogInformation($"connection established: {Context.UserIdentifier}"); ActiveRoomState activeRoomState = null; if (_sessionRepo.IsUserActive(Context.UserIdentifier)) { activeRoomState = await _roomManager.GetFullRoomState(RoomUser); ActiveUser.IsDisconnected = false; } else { CreateActiveUser(); } await InitClientGame(activeRoomState); await base.OnConnectedAsync(); }