예제 #1
0
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
        /// </summary>
        public void PlayerJoined(PlayerJoinedRequest request, Action <PlayerJoinedResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var context      = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
            var callSettings = apiSettings ?? PlayFabSettings.staticSettings;

            PlayFabHttp.MakeApiCall("/Matchmaker/PlayerJoined", request, AuthType.DevSecretKey, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
        }
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
        /// </summary>
        public async Task <PlayFabResult <PlayerJoinedResponse> > PlayerJoinedAsync(PlayerJoinedRequest request, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            await new PlayFabUtil.SynchronizationContextRemover();

            var requestContext  = request?.AuthenticationContext ?? authenticationContext;
            var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;

            if (requestSettings.DeveloperSecretKey == null)
            {
                throw new PlayFabException(PlayFabExceptionCode.DeveloperKeyNotSet, "DeveloperSecretKey must be set in your local or global settings to call this method");
            }

            var httpResult = await PlayFabHttp.DoPost("/Matchmaker/PlayerJoined", request, "X-SecretKey", requestSettings.DeveloperSecretKey, extraHeaders, requestSettings);

            if (httpResult is PlayFabError)
            {
                var error = (PlayFabError)httpResult;
                PlayFabSettings.GlobalErrorHandler?.Invoke(error);
                return(new PlayFabResult <PlayerJoinedResponse> {
                    Error = error, CustomData = customData
                });
            }

            var resultRawJson = (string)httpResult;
            var resultData    = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <PlayFabJsonSuccess <PlayerJoinedResponse> >(resultRawJson);
            var result        = resultData.data;

            return(new PlayFabResult <PlayerJoinedResponse> {
                Result = result, CustomData = customData
            });
        }
예제 #3
0
 internal static void NotifyPlayerJoined(int id)
 {
     try
     {
         TcpClient client = new TcpClient()
         {
             SendTimeout = 5, ReceiveTimeout = 5
         };
         client.Connect(MasterServerAddress, masterServerPort);
         using (Stream stream = client.GetStream())
         {
             var obj = new PlayerJoinedRequest()
             {
                 serverPort = Globals.listenPort, userId = id
             };
             var buffer = new byte[4096];
             var xs     = new XmlSerializer(typeof(PlayerJoinedRequest));
             xs.Serialize(new MemoryStream(buffer), obj);
             stream.Write(buffer, 0, buffer.Length);
         }
     }
     catch (Exception e)
     {
         Debug.LogError("Error sending PlayerJoined notification with the Master Server:\n" + e.ToString());
     }
 }
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
        /// </summary>
        public async Task <PlayFabResult <PlayerJoinedResponse> > PlayerJoinedAsync(PlayerJoinedRequest request, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var developerSecretKey = request.AuthenticationContext?.DeveloperSecretKey ?? (authenticationContext?.DeveloperSecretKey ?? PlayFabSettings.DeveloperSecretKey);

            if (developerSecretKey == null)
            {
                throw new PlayFabException(PlayFabExceptionCode.DeveloperKeyNotSet, "DeveloperSecretKey is not found in Request, Server Instance or PlayFabSettings");
            }

            var httpResult = await PlayFabHttp.DoPost("/Matchmaker/PlayerJoined", request, "X-SecretKey", developerSecretKey, extraHeaders, apiSettings);

            if (httpResult is PlayFabError)
            {
                var error = (PlayFabError)httpResult;
                PlayFabSettings.GlobalErrorHandler?.Invoke(error);
                return(new PlayFabResult <PlayerJoinedResponse> {
                    Error = error, CustomData = customData
                });
            }

            var resultRawJson = (string)httpResult;
            var resultData    = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <PlayFabJsonSuccess <PlayerJoinedResponse> >(resultRawJson);
            var result        = resultData.data;

            return(new PlayFabResult <PlayerJoinedResponse> {
                Result = result, CustomData = customData
            });
        }
예제 #5
0
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
        /// </summary>
        public static void PlayerJoined(PlayerJoinedRequest request, Action <PlayerJoinedResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null)
        {
            if (PlayFabSettings.DeveloperSecretKey == null)
            {
                throw new Exception("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
            }

            PlayFabHttp.MakeApiCall("/Matchmaker/PlayerJoined", request, AuthType.DevSecretKey, resultCallback, errorCallback, customData);
        }
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
        /// </summary>
        public static void PlayerJoined(PlayerJoinedRequest request, Action <PlayerJoinedResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            if (PlayFabSettings.DeveloperSecretKey == null)
            {
                throw new PlayFabException(PlayFabExceptionCode.DeveloperKeyNotSet, "Must have PlayFabSettings.DeveloperSecretKey set to call this method");
            }

            PlayFabHttp.MakeApiCall("/Matchmaker/PlayerJoined", request, AuthType.DevSecretKey, resultCallback, errorCallback, customData, extraHeaders);
        }
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
        /// </summary>
        public void PlayerJoined(PlayerJoinedRequest request, Action <PlayerJoinedResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var context      = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
            var callSettings = apiSettings ?? PlayFabSettings.staticSettings;

            if (string.IsNullOrEmpty(callSettings.DeveloperSecretKey))
            {
                throw new PlayFabException(PlayFabExceptionCode.DeveloperKeyNotSet, "Must set DeveloperSecretKey in settings to call this method");
            }
            PlayFabHttp.MakeApiCall("/Matchmaker/PlayerJoined", request, AuthType.DevSecretKey, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
        }
예제 #8
0
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
        /// </summary>
        public static void PlayerJoined(PlayerJoinedRequest request, ProcessApiCallback <PlayerJoinedResponse> resultCallback, ErrorCallback errorCallback, object customData = null)
        {
            if (PlayFabSettings.DeveloperSecretKey == null)
            {
                throw new Exception("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
            }

            string serializedJson = SimpleJson.SerializeObject(request, Util.ApiSerializerStrategy);
            Action <CallRequestContainer> callback = delegate(CallRequestContainer requestContainer)
            {
                ResultContainer <PlayerJoinedResponse> .HandleResults(requestContainer, resultCallback, errorCallback, null);
            };

            PlayFabHTTP.Post("/Matchmaker/PlayerJoined", serializedJson, "X-SecretKey", PlayFabSettings.DeveloperSecretKey, callback, request, customData);
        }
예제 #9
0
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
        /// </summary>
        /// <param name="LobbyId">Unique identifier of the Game Server Instance the user is joining. This must be a Game Server Instance started with the Matchmaker/StartGame API. (Required)</param>
        /// <param name="PlayFabId">PlayFab unique identifier for the player joining. (Required)</param>
        public static Task <PlayerJoinedResponse> PlayerJoined(string LobbyId, string PlayFabId,
                                                               PlayFabAuthenticationContext customAuthContext = null, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            PlayerJoinedRequest request = new PlayerJoinedRequest()
            {
                LobbyId   = LobbyId,
                PlayFabId = PlayFabId,
            };

            var context = GetContext(customAuthContext);

            return(PlayFabHttp.MakeApiCallAsync <PlayerJoinedResponse>("/Matchmaker/PlayerJoined", request,
                                                                       AuthType.DevSecretKey,
                                                                       customData, extraHeaders, context));
        }
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
        /// </summary>
        public static void PlayerJoined(PlayerJoinedRequest request, PlayerJoinedCallback resultCallback, ErrorCallback errorCallback, object customData = null)
        {
            if (PlayFabSettings.DeveloperSecretKey == null)
            {
                throw new Exception("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
            }

            string serializedJson = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings);
            Action <CallRequestContainer> callback = delegate(CallRequestContainer requestContainer)
            {
                PlayerJoinedResponse result = ResultContainer <PlayerJoinedResponse> .HandleResults(requestContainer, resultCallback, errorCallback);

                if (result != null)
                {
                }
            };

            PlayFabHTTP.Post("/Matchmaker/PlayerJoined", serializedJson, "X-SecretKey", PlayFabSettings.DeveloperSecretKey, callback, request, customData);
        }
예제 #11
0
 /// <summary>
 /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
 /// </summary>
 public static void PlayerJoined(PlayerJoinedRequest request, Action <PlayerJoinedResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
 {
     PlayFabHttp.MakeApiCall("/Matchmaker/PlayerJoined", request, AuthType.DevSecretKey, resultCallback, errorCallback, customData, extraHeaders);
 }
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
        /// </summary>
        public static async Task <PlayFabResult <PlayerJoinedResponse> > PlayerJoinedAsync(PlayerJoinedRequest request, object customData = null)
        {
            if (PlayFabSettings.DeveloperSecretKey == null)
            {
                throw new Exception("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
            }

            var httpResult = await PlayFabHttp.DoPost("/Matchmaker/PlayerJoined", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);

            if (httpResult is PlayFabError)
            {
                var error = (PlayFabError)httpResult;
                if (PlayFabSettings.GlobalErrorHandler != null)
                {
                    PlayFabSettings.GlobalErrorHandler(error);
                }
                return(new PlayFabResult <PlayerJoinedResponse> {
                    Error = error, CustomData = customData
                });
            }

            var resultRawJson = (string)httpResult;
            var resultData    = JsonWrapper.DeserializeObject <PlayFabJsonSuccess <PlayerJoinedResponse> >(resultRawJson);
            var result        = resultData.data;

            return(new PlayFabResult <PlayerJoinedResponse> {
                Result = result, CustomData = customData
            });
        }
 internal static void NotifyPlayerJoined(int id)
 {
     try
     {
         TcpClient client = new TcpClient() { SendTimeout = 5, ReceiveTimeout = 5 };
         client.Connect(MasterServerAddress, masterServerPort);
         using (Stream stream = client.GetStream())
         {
             var obj = new PlayerJoinedRequest() { serverPort = Globals.listenPort, userId = id };
             var buffer = new byte[4096];
             var xs = new XmlSerializer(typeof(PlayerJoinedRequest));
             xs.Serialize(new MemoryStream(buffer), obj);
             stream.Write(buffer, 0, buffer.Length);
         }
     }
     catch (Exception e)
     {
         Debug.LogError("Error sending PlayerJoined notification with the Master Server:\n" + e.ToString());
     }
 }
예제 #14
0
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
        /// </summary>
        public static async Task <PlayFabResult <PlayerJoinedResponse> > PlayerJoinedAsync(PlayerJoinedRequest request, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            if (PlayFabSettings.DeveloperSecretKey == null)
            {
                throw new PlayFabException(PlayFabExceptionCode.DeveloperKeyNotSet, "Must have PlayFabSettings.DeveloperSecretKey set to call this method");
            }

            var httpResult = await PlayFabHttp.DoPost("/Matchmaker/PlayerJoined", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey, extraHeaders);

            if (httpResult is PlayFabError)
            {
                var error = (PlayFabError)httpResult;
                PlayFabSettings.GlobalErrorHandler?.Invoke(error);
                return(new PlayFabResult <PlayerJoinedResponse> {
                    Error = error, CustomData = customData
                });
            }

            var resultRawJson = (string)httpResult;
            var resultData    = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <PlayFabJsonSuccess <PlayerJoinedResponse> >(resultRawJson);
            var result        = resultData.data;

            return(new PlayFabResult <PlayerJoinedResponse> {
                Result = result, CustomData = customData
            });
        }