public abstract bool CanUserJoinServer(JoinServerRequestMessage joinServerRequest);
public override bool CanUserJoinServer(JoinServerRequestMessage joinServerRequestMessage) { if (this.serverSettings.IsDebugLocalBuild) { return(true); } // Testing if this is a reconnect if (this.reconnectUsers.TryGetValue(joinServerRequestMessage.UserInfo.UserId, out ReconnectInfo reconnectInfo)) { if (this.isClosedToNewUsers && reconnectInfo.MatchmakerTicket == joinServerRequestMessage.CustomData) { joinServerRequestMessage.UserInfo.SetPlayFabId(reconnectInfo.PlayFabId); joinServerRequestMessage.UserInfo.SetUsername(reconnectInfo.Username); joinServerRequestMessage.UserInfo.SetDisplayName(reconnectInfo.DisplayName); return(true); } } var redeemMatchmakerTicket = PlayFabServerAPI.RedeemMatchmakerTicketAsync(new RedeemMatchmakerTicketRequest { LobbyId = this.serverSettings.LobbyId, Ticket = joinServerRequestMessage.CustomData, }); redeemMatchmakerTicket.Wait(); if (redeemMatchmakerTicket.Exception != null) { Debug.LogErrorFormat("PlayFabGameServer: Unable to Redeem Matchmaker Ticket: Exception {0}", redeemMatchmakerTicket.Exception.Message); } else if (redeemMatchmakerTicket.Result.Error != null) { Debug.LogErrorFormat("PlayFabGameServer: Unable to Redeem Matchmaker Ticket: Error {0}", redeemMatchmakerTicket.Result.Error.ErrorMessage); } else if (redeemMatchmakerTicket.Result.Result.TicketIsValid == false) { Debug.LogErrorFormat("PlayFabGameServer: Unable to Redeem Matchmaker Ticket: Error {0}", redeemMatchmakerTicket.Result.Error.ErrorMessage); } else { string playfabId = redeemMatchmakerTicket.Result.Result.UserInfo.PlayFabId; string displayName = redeemMatchmakerTicket.Result.Result.UserInfo.TitleInfo.DisplayName; string username = redeemMatchmakerTicket.Result.Result.UserInfo.Username; long userId = System.Convert.ToInt64(playfabId, 16); if (userId != joinServerRequestMessage.UserInfo.UserId) { Debug.LogErrorFormat("PlayFabGameServer: User Passed in invalid UserId {0}, Actual UserId {1}", joinServerRequestMessage.UserInfo.UserId, userId); this.NotifyMatchmakerPlayerLeft(playfabId); // TODO [bgish]: Set BadCallCount? return(false); } else { // We pased everything, so register the user and go! joinServerRequestMessage.UserInfo.SetPlayFabId(playfabId); joinServerRequestMessage.UserInfo.SetUsername(username); joinServerRequestMessage.UserInfo.SetDisplayName(displayName); // Remembering this conection so they can re-connect mid session and not have to if (this.reconnectUsers.ContainsKey(joinServerRequestMessage.UserInfo.UserId) == false) { this.reconnectUsers.Add(joinServerRequestMessage.UserInfo.UserId, new ReconnectInfo { PlayFabId = playfabId, Username = username, DisplayName = displayName, MatchmakerTicket = joinServerRequestMessage.CustomData, }); } return(true); } } return(false); }