public void CancelFindingMatchFor(PlayerData player) { QueuedPlayer queuedPlayer = GetQueueEntryFor(player); if (queuedPlayer != null) { queuedPlayer.matchFoundTaskCompletionSource?.SetResult(MatchMakingResult.GetCancelledResult(player)); } RemoveQueueEntry(queuedPlayer); }
public async void HandleMatchMakingRequestDataEvent(NetReceivedData receivedData) { if (receivedData.data is MatchMakingRequest matchMakingRequest) { receivedData.requestHandled = true; PlayerData playerData = BBServer.Instance.Systems.Database.GetPlayerDataById(matchMakingRequest.playerId); MatchMakingResult result = await FindAMatch(playerData, matchMakingRequest.matchMakingSettings); Log.D(result); receivedData.SendResponse(result); } }
private bool TryMatchingWithCurrentQueue(QueuedPlayer newQueueEntry, out MatchMakingResult result) { QueuedPlayer matchingPlayer = queue.Find(qp => qp.IsValidMatchFor(newQueueEntry)); if (matchingPlayer != null) { SetMatchFoundFor(matchingPlayer); var battleId = BBServer.Instance.Systems.BattleManager.CreateBattleFor(matchingPlayer.player, newQueueEntry.player, new BattleCreationData()); result = new MatchMakingResult(newQueueEntry.player, matchingPlayer.player, battleId, MatchMakingResult.Status.MatchFound); matchingPlayer.matchFoundTaskCompletionSource.SetResult(result); return(true); } result = null; return(false); }
private void TimeoutQueuedPlayer(QueuedPlayer queuedPlayer) { RemoveQueueEntry(queuedPlayer); queuedPlayer.matchFoundTaskCompletionSource.SetResult(MatchMakingResult.GetTimeoutResult(queuedPlayer.player)); }