| using System; |
| using System; |
| using System.Collections.Generic; |
| using System.Collections.Generic; |
| using PlayFab; |
| using PlayFab; |
| using PlayFab.MultiplayerModels; |
| using PlayFab.MultiplayerModels; |
| |
| |
| internal class ZPlayFabLobbySearch |
| internal class ZPlayFabLobbySearch |
| { |
| { |
| internal bool IsDone { get; private set; } |
| internal bool IsDone { get; private set; } |
| |
| |
| internal ZPlayFabLobbySearch(ZPlayFabMatchmakingSuccessCallback successAction, ZPlayFabMatchmakingFailedCallback failedAction, string searchFilter, string serverFilter, bool findFriendsOnly = false) |
| internal ZPlayFabLobbySearch(ZPlayFabMatchmakingSuccessCallback successAction, ZPlayFabMatchmakingFailedCallback failedAction, string searchFilter, string serverFilter, bool findFriendsOnly = false) |
| { |
| { |
| this.m_successAction = successAction; |
| this.m_successAction = successAction; |
| this.m_failedAction = failedAction; |
| this.m_failedAction = failedAction; |
| this.m_searchFilter = searchFilter; |
| this.m_searchFilter = searchFilter; |
| this.m_serverFilter = serverFilter; |
| this.m_serverFilter = serverFilter; |
| this.m_findFriendsOnly = findFriendsOnly; |
| this.m_findFriendsOnly = findFriendsOnly; |
| if (serverFilter == null) |
| if (serverFilter == null) |
| { |
| { |
| this.FindLobby(); |
| this.FindLobby(); |
| this.m_retries = 1; |
| this.m_retries = 1; |
| return; |
| return; |
| } |
| } |
| this.m_pages = this.CreatePages(); |
| this.m_pages = this.CreatePages(); |
| } |
| } |
| |
| |
| internal ZPlayFabLobbySearch(ZPlayFabMatchmakingSuccessCallback successAction, ZPlayFabMatchmakingFailedCallback failedAction, string searchFilter, bool joinLobby) |
| internal ZPlayFabLobbySearch(ZPlayFabMatchmakingSuccessCallback successAction, ZPlayFabMatchmakingFailedCallback failedAction, string searchFilter, bool joinLobby) |
| { |
| { |
| this.m_successAction = successAction; |
| this.m_successAction = successAction; |
| this.m_failedAction = failedAction; |
| this.m_failedAction = failedAction; |
| this.m_searchFilter = searchFilter; |
| this.m_searchFilter = searchFilter; |
| this.m_joinLobby = joinLobby; |
| this.m_joinLobby = joinLobby; |
| if (joinLobby) |
| if (joinLobby) |
| { |
| { |
| this.FindLobby(); |
| this.FindLobby(); |
| this.m_retries = 3; |
| this.m_retries = 3; |
| } |
| } |
| } |
| } |
| |
| |
| private Queue<int> CreatePages() |
| private Queue<int> CreatePages() |
| { |
| { |
| Queue<int> queue = new Queue<int>(); |
| Queue<int> queue = new Queue<int>(); |
| for (int i = 0; i < 4; i++) |
| for (int i = 0; i < 4; i++) |
| { |
| { |
| queue.Enqueue(i); |
| queue.Enqueue(i); |
| } |
| } |
| return queue; |
| return queue; |
| } |
| } |
| |
| |
| internal void Update(float deltaTime) |
| internal void Update(float deltaTime) |
| { |
| { |
| if (this.m_retryIn > 0f) |
| if (this.m_retryIn > 0f) |
| { |
| { |
| this.m_retryIn -= deltaTime; |
| this.m_retryIn -= deltaTime; |
| if (this.m_retryIn <= 0f) |
| if (this.m_retryIn <= 0f) |
| { |
| { |
| this.FindLobby(); |
| this.FindLobby(); |
| } |
| } |
| } |
| } |
| this.TickAPICallRateLimiter(); |
| this.TickAPICallRateLimiter(); |
| } |
| } |
| |
| |
| internal void FindLobby() |
| internal void FindLobby() |
| { |
| { |
| if (this.m_serverFilter == null) |
| if (this.m_serverFilter == null) |
| { |
| { |
| FindLobbiesRequest request = new FindLobbiesRequest |
| FindLobbiesRequest request = new FindLobbiesRequest |
| { |
| { |
| Filter = this.m_searchFilter |
| Filter = this.m_searchFilter |
| }; |
| }; |
| this.QueueAPICall(delegate |
| this.QueueAPICall(delegate |
| { |
| { |
| PlayFabMultiplayerAPI.FindLobbies(request, new Action<FindLobbiesResult>(this.OnFindLobbySuccess), new Action<PlayFabError>(this.OnFindLobbyFailed), null, null); |
| PlayFabMultiplayerAPI.FindLobbies(request, new Action<FindLobbiesResult>(this.OnFindLobbySuccess), new Action<PlayFabError>(this.OnFindLobbyFailed), null, null); |
| }); |
| }); |
| return; |
| return; |
| } |
| } |
| this.FindLobbyWithPagination(this.m_pages.Dequeue()); |
| this.FindLobbyWithPagination(this.m_pages.Dequeue()); |
| } |
| } |
| |
| |
| private void FindLobbyWithPagination(int page) |
| private void FindLobbyWithPagination(int page) |
| { |
| { |
| FindLobbiesRequest request = new FindLobbiesRequest |
| FindLobbiesRequest request = new FindLobbiesRequest |
| { |
| { |
| Filter = this.m_searchFilter + string.Format(" and {0} eq {1}", "number_key11", page), |
| Filter = this.m_searchFilter + string.Format(" and {0} eq {1}", "number_key11", page), |
| Pagination = new PaginationRequest |
| Pagination = new PaginationRequest |
| { |
| { |
| PageSizeRequested = new uint?(50U) |
| PageSizeRequested = new uint?(50U) |
| } |
| } |
| }; |
| }; |
| if (this.m_verboseLog) |
| if (this.m_verboseLog) |
| { |
| { |
| ZLog.Log(string.Format("Page {0}, {1} remains: {2}", page, this.m_pages.Count, request.Filter)); |
| ZLog.Log(string.Format("Page {0}, {1} remains: {2}", page, this.m_pages.Count, request.Filter)); |
| } |
| } |
| this.QueueAPICall(delegate |
| this.QueueAPICall(delegate |
| { |
| { |
| PlayFabMultiplayerAPI.FindLobbies(request, new Action<FindLobbiesResult>(this.OnFindServersSuccess), new Action<PlayFabError>(this.OnFindLobbyFailed), null, null); |
| PlayFabMultiplayerAPI.FindLobbies(request, new Action<FindLobbiesResult>(this.OnFindServersSuccess), new Action<PlayFabError>(this.OnFindLobbyFailed), null, null); |
| }); |
| }); |
| } |
| } |
| |
| |
| private void RetryOrFail(string error) |
| private void RetryOrFail(string error) |
| { |
| { |
| if (this.m_retries > 0) |
| if (this.m_retries > 0) |
| { |
| { |
| this.m_retries--; |
| this.m_retries--; |
| this.m_retryIn = 1f; |
| this.m_retryIn = 1f; |
| return; |
| return; |
| } |
| } |
| ZLog.Log(string.Format("PlayFab lobby matching search filter '{0}': {1}", this.m_searchFilter, error)); |
| ZLog.Log(string.Format("PlayFab lobby matching search filter '{0}': {1}", this.m_searchFilter, error)); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.Unknown); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.Unknown); |
| } |
| } |
| |
| |
| private void OnFindLobbyFailed(PlayFabError error) |
| private void OnFindLobbyFailed(PlayFabError error) |
| { |
| { |
| if (!this.IsDone) |
| if (!this.IsDone) |
| { |
| { |
| this.RetryOrFail(error.ToString()); |
| this.RetryOrFail(error.ToString()); |
| } |
| } |
| } |
| } |
| |
| |
| private void OnFindLobbySuccess(FindLobbiesResult result) |
| private void OnFindLobbySuccess(FindLobbiesResult result) |
| { |
| { |
| if (this.IsDone) |
| if (this.IsDone) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (result.Lobbies.Count == 0) |
| if (result.Lobbies.Count == 0) |
| { |
| { |
| this.RetryOrFail("Got back zero lobbies"); |
| this.RetryOrFail("Got back zero lobbies"); |
| return; |
| return; |
| } |
| } |
| LobbySummary lobbySummary = result.Lobbies[0]; |
| LobbySummary lobbySummary = result.Lobbies[0]; |
| if (result.Lobbies.Count > 1) |
| if (result.Lobbies.Count > 1) |
| { |
| { |
| ZLog.LogWarning(string.Format("Expected zero or one lobby got {0} matching lobbies, returning newest lobby", result.Lobbies.Count)); |
| ZLog.LogWarning(string.Format("Expected zero or one lobby got {0} matching lobbies, returning newest lobby", result.Lobbies.Count)); |
| long num = long.Parse(lobbySummary.SearchData["string_key9"]); |
| long num = long.Parse(lobbySummary.SearchData["string_key9"]); |
| foreach (LobbySummary lobbySummary2 in result.Lobbies) |
| foreach (LobbySummary lobbySummary2 in result.Lobbies) |
| { |
| { |
| long num2 = long.Parse(lobbySummary2.SearchData["string_key9"]); |
| long num2 = long.Parse(lobbySummary2.SearchData["string_key9"]); |
| if (num < num2) |
| if (num < num2) |
| { |
| { |
| lobbySummary = lobbySummary2; |
| lobbySummary = lobbySummary2; |
| num = num2; |
| num = num2; |
| } |
| } |
| } |
| } |
| } |
| } |
| if (this.m_joinLobby) |
| if (this.m_joinLobby) |
| { |
| { |
| this.JoinLobby(lobbySummary.LobbyId, lobbySummary.ConnectionString); |
| this.JoinLobby(lobbySummary.LobbyId, lobbySummary.ConnectionString); |
| ZPlayFabMatchmaking.JoinCode = lobbySummary.SearchData["string_key4"]; |
| ZPlayFabMatchmaking.JoinCode = lobbySummary.SearchData["string_key4"]; |
| return; |
| return; |
| } |
| } |
| this.DeliverLobby(lobbySummary); |
| this.DeliverLobby(lobbySummary); |
| this.IsDone = true; |
| this.IsDone = true; |
| } |
| } |
| |
| |
| private void JoinLobby(string lobbyId, string connectionString) |
| private void JoinLobby(string lobbyId, string connectionString) |
| { |
| { |
| JoinLobbyRequest request = new JoinLobbyRequest |
| JoinLobbyRequest request = new JoinLobbyRequest |
| { |
| { |
| ConnectionString = connectionString, |
| ConnectionString = connectionString, |
| MemberEntity = ZPlayFabMatchmaking.GetEntityKeyForLocalUser() |
| MemberEntity = ZPlayFabMatchmaking.GetEntityKeyForLocalUser() |
| }; |
| }; |
| Action<JoinLobbyResult> <>9__1; |
| Action<JoinLobbyResult> <>9__1; |
| Action<PlayFabError> <>9__2; |
| Action<PlayFabError> <>9__2; |
| this.QueueAPICall(delegate |
| this.QueueAPICall(delegate |
| { |
| { |
| JoinLobbyRequest request2 = request; |
| JoinLobbyRequest request2 = request; |
| Action<JoinLobbyResult> action; |
| Action<JoinLobbyResult> action; |
| if ((action = <>9__1) == null) |
| if ((action = <>9__1) == null) |
| { |
| { |
| action = (<>9__1 = delegate(JoinLobbyResult result) |
| action = (<>9__1 = delegate(JoinLobbyResult result) |
| { |
| { |
| this.OnJoinLobbySuccess(result.LobbyId); |
| this.OnJoinLobbySuccess(result.LobbyId); |
| }); |
| }); |
| } |
| } |
| Action<PlayFabError> action2; |
| Action<PlayFabError> action2; |
| if ((action2 = <>9__2) == null) |
| if ((action2 = <>9__2) == null) |
| { |
| { |
| action2 = (<>9__2 = delegate(PlayFabError error) |
| action2 = (<>9__2 = delegate(PlayFabError error) |
| { |
| { |
| this.OnJoinLobbyFailed(error, lobbyId); |
| this.OnJoinLobbyFailed(error, lobbyId); |
| }); |
| }); |
| } |
| } |
| PlayFabMultiplayerAPI.JoinLobby(request2, action, action2, null, null); |
| PlayFabMultiplayerAPI.JoinLobby(request2, action, action2, null, null); |
| }); |
| }); |
| } |
| } |
| |
| |
| private void OnJoinLobbySuccess(string lobbyId) |
| private void OnJoinLobbySuccess(string lobbyId) |
| { |
| { |
| if (this.IsDone) |
| if (this.IsDone) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| GetLobbyRequest request = new GetLobbyRequest |
| GetLobbyRequest request = new GetLobbyRequest |
| { |
| { |
| LobbyId = lobbyId |
| LobbyId = lobbyId |
| }; |
| }; |
| this.QueueAPICall(delegate |
| this.QueueAPICall(delegate |
| { |
| { |
| PlayFabMultiplayerAPI.GetLobby(request, new Action<GetLobbyResult>(this.OnGetLobbySuccess), new Action<PlayFabError>(this.OnGetLobbyFailed), null, null); |
| PlayFabMultiplayerAPI.GetLobby(request, new Action<GetLobbyResult>(this.OnGetLobbySuccess), new Action<PlayFabError>(this.OnGetLobbyFailed), null, null); |
| }); |
| }); |
| } |
| } |
| |
| |
| private void OnJoinLobbyFailed(PlayFabError error, string lobbyId) |
| private void OnJoinLobbyFailed(PlayFabError error, string lobbyId) |
| { |
| { |
| PlayFabErrorCode error2 = error.Error; |
| PlayFabErrorCode error2 = error.Error; |
| if (error2 <= PlayFabErrorCode.APIClientRequestRateLimitExceeded) |
| if (error2 <= PlayFabErrorCode.APIClientRequestRateLimitExceeded) |
| { |
| { |
| if (error2 != PlayFabErrorCode.APIRequestLimitExceeded && error2 != PlayFabErrorCode.APIClientRequestRateLimitExceeded) |
| if (error2 != PlayFabErrorCode.APIRequestLimitExceeded && error2 != PlayFabErrorCode.APIClientRequestRateLimitExceeded) |
| { |
| { |
| goto IL_5D; |
| goto IL_5D; |
| } |
| } |
| } |
| } |
| else |
| else |
| { |
| { |
| if (error2 == PlayFabErrorCode.LobbyPlayerAlreadyJoined) |
| if (error2 == PlayFabErrorCode.LobbyPlayerAlreadyJoined) |
| { |
| { |
| this.OnJoinLobbySuccess(lobbyId); |
| this.OnJoinLobbySuccess(lobbyId); |
| return; |
| return; |
| } |
| } |
| if (error2 == PlayFabErrorCode.LobbyNotJoinable) |
| if (error2 == PlayFabErrorCode.LobbyNotJoinable) |
| { |
| { |
| ZLog.Log("Can't join lobby because it's not joinable, likely because it's full."); |
| ZLog.Log("Can't join lobby because it's not joinable, likely because it's full."); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.ServerFull); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.ServerFull); |
| return; |
| return; |
| } |
| } |
| if (error2 != PlayFabErrorCode.LobbyPlayerMaxLobbyLimitExceeded) |
| if (error2 != PlayFabErrorCode.LobbyPlayerMaxLobbyLimitExceeded) |
| { |
| { |
| goto IL_5D; |
| goto IL_5D; |
| } |
| } |
| } |
| } |
| this.OnFailed(ZPLayFabMatchmakingFailReason.APIRequestLimitExceeded); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.APIRequestLimitExceeded); |
| return; |
| return; |
| IL_5D: |
| IL_5D: |
| ZLog.LogError("Failed to get lobby: " + error.ToString()); |
| ZLog.LogError("Failed to get lobby: " + error.ToString()); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.Unknown); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.Unknown); |
| } |
| } |
| |
| |
| private void DeliverLobby(LobbySummary lobbySummary) |
| private void DeliverLobby(LobbySummary lobbySummary) |
| { |
| { |
| PlayFabMatchmakingServerData playFabMatchmakingServerData = ZPlayFabLobbySearch.ToServerData(lobbySummary.LobbyId, lobbySummary.CurrentPlayers, lobbySummary.SearchData, null, true); |
| PlayFabMatchmakingServerData playFabMatchmakingServerData = ZPlayFabLobbySearch.ToServerData(lobbySummary.LobbyId, lobbySummary.CurrentPlayers, lobbySummary.SearchData, null, true); |
| if (this.m_verboseLog && playFabMatchmakingServerData != null) |
| if (this.m_verboseLog && playFabMatchmakingServerData != null) |
| { |
| { |
| ZLog.Log("Deliver server data\n" + playFabMatchmakingServerData.ToString()); |
| ZLog.Log("Deliver server data\n" + playFabMatchmakingServerData.ToString()); |
| } |
| } |
| this.m_successAction(playFabMatchmakingServerData); |
| this.m_successAction(playFabMatchmakingServerData); |
| if (this.m_findFriendsOnly) |
| if (this.m_findFriendsOnly) |
| { |
| { |
| this.m_failedAction(ZPLayFabMatchmakingFailReason.None); |
| this.m_failedAction(ZPLayFabMatchmakingFailReason.None); |
| } |
| } |
| } |
| } |
| |
| |
| private void OnFindServersSuccess(FindLobbiesResult result) |
| private void OnFindServersSuccess(FindLobbiesResult result) |
| { |
| { |
| if (this.IsDone) |
| if (this.IsDone) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| foreach (LobbySummary lobbySummary in result.Lobbies) |
| foreach (LobbySummary lobbySummary in result.Lobbies) |
| { |
| { |
| if (lobbySummary.SearchData["string_key5"].ToLowerInvariant().Contains(this.m_serverFilter.ToLowerInvariant())) |
| if (lobbySummary.SearchData["string_key5"].ToLowerInvariant().Contains(this.m_serverFilter.ToLowerInvariant())) |
| { |
| { |
| this.DeliverLobby(lobbySummary); |
| this.DeliverLobby(lobbySummary); |
| } |
| } |
| } |
| } |
| if (this.m_pages.Count == 0) |
| if (this.m_pages.Count == 0) |
| { |
| { |
| this.OnFailed(ZPLayFabMatchmakingFailReason.None); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.None); |
| return; |
| return; |
| } |
| } |
| this.FindLobbyWithPagination(this.m_pages.Dequeue()); |
| this.FindLobbyWithPagination(this.m_pages.Dequeue()); |
| } |
| } |
| |
| |
| private void OnGetLobbySuccess(GetLobbyResult result) |
| private void OnGetLobbySuccess(GetLobbyResult result) |
| { |
| { |
| PlayFabMatchmakingServerData playFabMatchmakingServerData = ZPlayFabLobbySearch.ToServerData(result); |
| PlayFabMatchmakingServerData playFabMatchmakingServerData = ZPlayFabLobbySearch.ToServerData(result); |
| if (this.IsDone) |
| if (this.IsDone) |
| { |
| { |
| this.OnFailed(ZPLayFabMatchmakingFailReason.Cancelled); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.Cancelled); |
| return; |
| return; |
| } |
| } |
| if (playFabMatchmakingServerData == null) |
| if (playFabMatchmakingServerData == null) |
| { |
| { |
| this.OnFailed(ZPLayFabMatchmakingFailReason.InvalidServerData); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.InvalidServerData); |
| return; |
| return; |
| } |
| } |
| this.IsDone = true; |
| this.IsDone = true; |
| ZLog.Log("Get Lobby\n" + playFabMatchmakingServerData.ToString()); |
| ZLog.Log("Get Lobby\n" + playFabMatchmakingServerData.ToString()); |
| this.m_successAction(playFabMatchmakingServerData); |
| this.m_successAction(playFabMatchmakingServerData); |
| } |
| } |
| |
| |
| private void OnGetLobbyFailed(PlayFabError error) |
| private void OnGetLobbyFailed(PlayFabError error) |
| { |
| { |
| ZLog.LogError("Failed to get lobby: " + error.ToString()); |
| ZLog.LogError("Failed to get lobby: " + error.ToString()); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.Unknown); |
| this.OnFailed(ZPLayFabMatchmakingFailReason.Unknown); |
| } |
| } |
| |
| |
| private static PlayFabMatchmakingServerData ToServerData(string lobbyID, uint playerCount, Dictionary<string, string> searchData, Dictionary<string, string> lobbyData = null, bool subtractOneFromPlayerCountIfDedicated = false) |
| private static PlayFabMatchmakingServerData ToServerData(string lobbyID, uint playerCount, Dictionary<string, string> searchData, Dictionary<string, string> lobbyData = null, bool subtractOneFromPlayerCountIfDedicated = false) |
| { |
| { |
| PlayFabMatchmakingServerData playFabMatchmakingServerData; |
| PlayFabMatchmakingServerData playFabMatchmakingServerData; |
| try |
| try |
| { |
| { |
| bool flag; |
| bool flag; |
| bool flag2; |
| bool flag2; |
| long num; |
| long num; |
| if (!bool.TryParse(searchData["string_key3"], out flag) || !bool.TryParse(searchData["string_key7"], out flag2) || !long.TryParse(searchData["string_key9"], out num)) |
| if (!bool.TryParse(searchData["string_key3"], out flag) || !bool.TryParse(searchData["string_key7"], out flag2) || !long.TryParse(searchData["string_key9"], out num)) |
| { |
| { |
| ZLog.LogWarning("Got PlayFab lobby entry with invalid data"); |
| ZLog.LogWarning("Got PlayFab lobby entry with invalid data"); |
| playFabMatchmakingServerData = null; |
| playFabMatchmakingServerData = null; |
| } |
| } |
| else |
| else |
| { |
| { |
| string text = searchData["string_key6"]; |
| string text = searchData["string_key6"]; |
| uint num2 = uint.Parse(searchData["number_key13"]); |
| uint num2 = uint.Parse(searchData["number_key13"]); |
| GameVersion gameVersion; |
| GameVersion gameVersion; |
| if (!GameVersion.TryParseGameVersion(text, out gameVersion) || gameVersion < global::Version.FirstVersionWithNetworkVersion) |
| if (!GameVersion.TryParseGameVersion(text, out gameVersion) || gameVersion < global::Version.FirstVersionWithNetworkVersion) |
| { |
| { |
| num2 = 0U; |
| num2 = 0U; |
| } |
| } |
| string text2; |
| string text2; |
| Dictionary<string, string> dictionary; |
| Dictionary<string, string> dictionary; |
| List<string> list; |
| List<string> list; |
| . | if (num2 != 23U || !searchData.TryGetValue("string_key14", out text2) || !StringUtils.TryDecodeStringAsIDictionary<Dictionary<string, string>>(text2, out dictionary) || !ServerOptionsGUI.TryConvertCompactKVPToModifierKeys<List<string>>(dictionary, out list)) |
| if (num2 != 27U || !searchData.TryGetValue("string_key14", out text2) || !StringUtils.TryDecodeStringAsIDictionary<Dictionary<string, string>>(text2, out dictionary) || !ServerOptionsGUI.TryConvertCompactKVPToModifierKeys<List<string>>(dictionary, out list)) |
| { |
| { |
| list = new List<string>(); |
| list = new List<string>(); |
| } |
| } |
| PlayFabMatchmakingServerData playFabMatchmakingServerData2 = new PlayFabMatchmakingServerData |
| PlayFabMatchmakingServerData playFabMatchmakingServerData2 = new PlayFabMatchmakingServerData |
| { |
| { |
| isCommunityServer = flag, |
| isCommunityServer = flag, |
| isDedicatedServer = flag2, |
| isDedicatedServer = flag2, |
| joinCode = searchData["string_key4"], |
| joinCode = searchData["string_key4"], |
| lobbyId = lobbyID, |
| lobbyId = lobbyID, |
| numPlayers = ((flag2 && subtractOneFromPlayerCountIfDedicated) ? (playerCount - 1U) : playerCount), |
| numPlayers = ((flag2 && subtractOneFromPlayerCountIfDedicated) ? (playerCount - 1U) : playerCount), |
| remotePlayerId = searchData["string_key1"], |
| remotePlayerId = searchData["string_key1"], |
| serverIp = searchData["string_key10"], |
| serverIp = searchData["string_key10"], |
| serverName = searchData["string_key5"], |
| serverName = searchData["string_key5"], |
| tickCreated = num, |
| tickCreated = num, |
| gameVersion = gameVersion, |
| gameVersion = gameVersion, |
| modifiers = list, |
| modifiers = list, |
| networkVersion = num2, |
| networkVersion = num2, |
| xboxUserId = searchData["string_key8"], |
| xboxUserId = searchData["string_key8"], |
| platformRestriction = searchData["string_key12"] |
| platformRestriction = searchData["string_key12"] |
| }; |
| }; |
| if (lobbyData != null) |
| if (lobbyData != null) |
| { |
| { |
| playFabMatchmakingServerData2.havePassword = bool.Parse(lobbyData[PlayFabAttrKey.HavePassword.ToKeyString()]); |
| playFabMatchmakingServerData2.havePassword = bool.Parse(lobbyData[PlayFabAttrKey.HavePassword.ToKeyString()]); |
| playFabMatchmakingServerData2.networkId = lobbyData[PlayFabAttrKey.NetworkId.ToKeyString()]; |
| playFabMatchmakingServerData2.networkId = lobbyData[PlayFabAttrKey.NetworkId.ToKeyString()]; |
| playFabMatchmakingServerData2.worldName = lobbyData[PlayFabAttrKey.WorldName.ToKeyString()]; |
| playFabMatchmakingServerData2.worldName = lobbyData[PlayFabAttrKey.WorldName.ToKeyString()]; |
| } |
| } |
| playFabMatchmakingServerData = playFabMatchmakingServerData2; |
| playFabMatchmakingServerData = playFabMatchmakingServerData2; |
| } |
| } |
| } |
| } |
| catch (KeyNotFoundException) |
| catch (KeyNotFoundException) |
| { |
| { |
| ZLog.LogWarning("Got PlayFab lobby entry with missing key(s)"); |
| ZLog.LogWarning("Got PlayFab lobby entry with missing key(s)"); |
| playFabMatchmakingServerData = null; |
| playFabMatchmakingServerData = null; |
| } |
| } |
| catch |
| catch |
| { |
| { |
| playFabMatchmakingServerData = null; |
| playFabMatchmakingServerData = null; |
| } |
| } |
| return playFabMatchmakingServerData; |
| return playFabMatchmakingServerData; |
| } |
| } |
| |
| |
| private static PlayFabMatchmakingServerData ToServerData(GetLobbyResult result) |
| private static PlayFabMatchmakingServerData ToServerData(GetLobbyResult result) |
| { |
| { |
| return ZPlayFabLobbySearch.ToServerData(result.Lobby.LobbyId, (uint)result.Lobby.Members.Count, result.Lobby.SearchData, result.Lobby.LobbyData, false); |
| return ZPlayFabLobbySearch.ToServerData(result.Lobby.LobbyId, (uint)result.Lobby.Members.Count, result.Lobby.SearchData, result.Lobby.LobbyData, false); |
| } |
| } |
| |
| |
| private void OnFailed(ZPLayFabMatchmakingFailReason failReason) |
| private void OnFailed(ZPLayFabMatchmakingFailReason failReason) |
| { |
| { |
| if (!this.IsDone) |
| if (!this.IsDone) |
| { |
| { |
| this.IsDone = true; |
| this.IsDone = true; |
| if (this.m_failedAction != null) |
| if (this.m_failedAction != null) |
| { |
| { |
| this.m_failedAction(failReason); |
| this.m_failedAction(failReason); |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| internal void Cancel() |
| internal void Cancel() |
| { |
| { |
| this.IsDone = true; |
| this.IsDone = true; |
| } |
| } |
| |
| |
| private void QueueAPICall(ZPlayFabLobbySearch.QueueableAPICall apiCallDelegate) |
| private void QueueAPICall(ZPlayFabLobbySearch.QueueableAPICall apiCallDelegate) |
| { |
| { |
| this.m_APICallQueue.Enqueue(apiCallDelegate); |
| this.m_APICallQueue.Enqueue(apiCallDelegate); |
| this.TickAPICallRateLimiter(); |
| this.TickAPICallRateLimiter(); |
| } |
| } |
| |
| |
| private void TickAPICallRateLimiter() |
| private void TickAPICallRateLimiter() |
| { |
| { |
| if (this.m_APICallQueue.Count <= 0) |
| if (this.m_APICallQueue.Count <= 0) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if ((DateTime.UtcNow - this.m_previousAPICallTime).TotalSeconds >= 2.0) |
| if ((DateTime.UtcNow - this.m_previousAPICallTime).TotalSeconds >= 2.0) |
| { |
| { |
| this.m_APICallQueue.Dequeue()(); |
| this.m_APICallQueue.Dequeue()(); |
| this.m_previousAPICallTime = DateTime.UtcNow; |
| this.m_previousAPICallTime = DateTime.UtcNow; |
| } |
| } |
| } |
| } |
| |
| |
| private readonly ZPlayFabMatchmakingSuccessCallback m_successAction; |
| private readonly ZPlayFabMatchmakingSuccessCallback m_successAction; |
| |
| |
| private readonly ZPlayFabMatchmakingFailedCallback m_failedAction; |
| private readonly ZPlayFabMatchmakingFailedCallback m_failedAction; |
| |
| |
| private readonly string m_searchFilter; |
| private readonly string m_searchFilter; |
| |
| |
| private readonly string m_serverFilter; |
| private readonly string m_serverFilter; |
| |
| |
| private readonly Queue<int> m_pages; |
| private readonly Queue<int> m_pages; |
| |
| |
| private readonly bool m_joinLobby; |
| private readonly bool m_joinLobby; |
| |
| |
| private readonly bool m_verboseLog; |
| private readonly bool m_verboseLog; |
| |
| |
| private readonly bool m_findFriendsOnly; |
| private readonly bool m_findFriendsOnly; |
| |
| |
| private int m_retries; |
| private int m_retries; |
| |
| |
| private float m_retryIn = -1f; |
| private float m_retryIn = -1f; |
| |
| |
| private const float rateLimit = 2f; |
| private const float rateLimit = 2f; |
| |
| |
| private DateTime m_previousAPICallTime = DateTime.MinValue; |
| private DateTime m_previousAPICallTime = DateTime.MinValue; |
| |
| |
| private Queue<ZPlayFabLobbySearch.QueueableAPICall> m_APICallQueue = new Queue<ZPlayFabLobbySearch.QueueableAPICall>(); |
| private Queue<ZPlayFabLobbySearch.QueueableAPICall> m_APICallQueue = new Queue<ZPlayFabLobbySearch.QueueableAPICall>(); |
| |
| |
| private delegate void QueueableAPICall(); |
| private delegate void QueueableAPICall(); |
| } |
| } |
| |
| |