コード例 #1
0
        private void SaveCallback(IHttpResponse request, object userState)
        {
            ICloseGameCallInfo info = (ICloseGameCallInfo)request.CallInfo;

            if (request.Status == HttpRequestQueueResult.Success)
            {
                this.PluginHost.LogDebug(string.Format("Http request to {0} - done.", info.ActorCount > 0 ? "save" : "close"));
                info.Continue();
                return;
            }

            var msg = string.Format("Failed save game request on {0} : {1}", this.gameClosedUrl, request.Reason);

            this.ReportError(msg);
            info.Continue();
        }
コード例 #2
0
ファイル: TestExtra.cs プロジェクト: cernysw/UnityDemo
        public override void OnCloseGame(ICloseGameCallInfo info)
        {
            this.onCloseEvent.Set();
            if (this.PluginHost.GameId.EndsWith("OnCloseForgotCall"))
            {
                return;
            }

            if (this.PluginHost.GameId.EndsWith("ReinitGame"))
            {
                this.allowContinueEvent.WaitOne();
            }

            var property = (string)this.PluginHost.GameProperties["key"];

            if (property != null && (property == "OnCloseGameException" || property == "CloseFatalPlugin"))
            {
                throw new Exception("OnCloseGameException for test");
            }

            info.Continue();
        }
コード例 #3
0
ファイル: TestExtra.cs プロジェクト: JerryBian/PhotonSample
        public override void OnCloseGame(ICloseGameCallInfo info)
        {
            this.onCloseEvent.Set();
            if (this.PluginHost.GameId.EndsWith("OnCloseForgotCall"))
            {
                return;
            }

            if (this.PluginHost.GameId.EndsWith("ReinitGame"))
            {
                this.allowContinueEvent.WaitOne();
            }

            var property = (string)this.PluginHost.GameProperties["key"];
            if (property != null && (property == "OnCloseGameException" || property == "CloseFatalPlugin"))
            {
                throw new Exception("OnCloseGameException for test");
            }

            info.Continue();
        }
コード例 #4
0
ファイル: PluginBase.cs プロジェクト: theGameShop/Flipper
 /// <summary>
 /// Calls info.Continue(). Override to change.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 public virtual void OnCloseGame(ICloseGameCallInfo info)
 {
     System.Diagnostics.Debug.Assert(this.PluginHost != null);
     info.Continue();
 }
コード例 #5
0
ファイル: ErrorPlugin.cs プロジェクト: JerryBian/PhotonSample
 /// <summary>
 /// Calls info.Continue
 /// </summary>
 /// <param name="info"></param>
 public void OnCloseGame(ICloseGameCallInfo info)
 {
     info.Continue();
 }
コード例 #6
0
        public override void OnCloseGame(ICloseGameCallInfo info)
        {
            if (!this.SuccesfullLoaded)
            {
                this.PluginHost.LogDebug("Skipped further OnCloseGame: not succesfullyloaded.");
                info.Continue();
                return;
            }

            if (this.IsPersistent)
            {
                this.PluginHost.LogDebug("OnCloseGame");

                var state = info.ActorCount > 0 ? this.GetGameState() : null;

                var actors = new List <object>();
                foreach (var actor in this.PluginHost.GameActors)
                {
                    actors.Add(new Actor {
                        ActorNr = actor.ActorNr, UserId = actor.UserId
                    });
                }

                this.PluginHost.LogDebug(string.Format("Http request to {0}", info.ActorCount > 0 ? "save" : "close"));

                this.PostJsonRequest(
                    this.gameClosedUrl,
                    new WebhooksRequest
                {
                    Type       = info.ActorCount > 0 ? "Save" : "Close",
                    GameId     = this.PluginHost.GameId,
                    AppId      = this.AppId,
                    AppVersion = this.AppVersion,
                    Region     = this.Region,
                    ActorCount = info.ActorCount,
                    State      = state,
                    AuthCookie = null,
                },
                    this.SaveCallback,
                    info,
                    callAsync: false);
            }
            else
            {
                if (!string.IsNullOrEmpty(this.gameClosedUrl))
                {
                    this.PostJsonRequest(
                        this.gameClosedUrl,
                        new WebhooksRequest
                    {
                        Type       = "Close",
                        GameId     = this.PluginHost.GameId,
                        AppId      = this.AppId,
                        AppVersion = this.AppVersion,
                        Region     = this.Region,
                        ActorCount = 0
                    },
                        this.LogIfFailedCallback,
                        callAsync: false);
                }

                info.Continue();
            }
        }
コード例 #7
0
ファイル: ErrorPlugin.cs プロジェクト: theGameShop/Flipper
 /// <summary>
 /// Calls info.Continue
 /// </summary>
 /// <param name="info"></param>
 public void OnCloseGame(ICloseGameCallInfo info)
 {
     info.Continue();
 }
コード例 #8
0
        public override void OnCloseGame(ICloseGameCallInfo info)
        {
            if (!this.SuccesfullLoaded)
            {
                this.PluginHost.LogDebug("Skipped further OnCloseGame: not succesfullyloaded.");
                info.Continue();
                return;
            }

            if (this.IsPersistent)
            {
                this.PluginHost.LogDebug("OnCloseGame");

                var state = info.ActorCount > 0 ? this.GetGameState() : null;

                var actors = new List<object>();
                foreach (var actor in this.PluginHost.GameActors)
                {
                    actors.Add(new Actor { ActorNr = actor.ActorNr, UserId = actor.UserId });
                }

                this.PluginHost.LogDebug(string.Format("Http request to {0}", info.ActorCount > 0 ? "save" : "close"));

                this.PostJsonRequest(
                    this.gameClosedUrl,
                    new WebhooksRequest
                    {
                        Type = info.ActorCount > 0 ? "Save" : "Close",
                        GameId = this.PluginHost.GameId,
                        AppId = this.AppId,
                        AppVersion = this.AppVersion,
                        Region = this.Region,
                        ActorCount = info.ActorCount,
                        State = state,
                        AuthCookie = null,
                    },
                    this.SaveCallback,
                    info,
                    callAsync: false);
            }
            else
            {
                if (!string.IsNullOrEmpty(this.gameClosedUrl))
                {
                    this.PostJsonRequest(
                        this.gameClosedUrl,
                        new WebhooksRequest
                        {
                            Type = "Close",
                            GameId = this.PluginHost.GameId,
                            AppId = this.AppId,
                            AppVersion = this.AppVersion,
                            Region = this.Region,
                            ActorCount = 0
                        },
                        this.LogIfFailedCallback,
                        callAsync: false);
                }

                info.Continue();
            }
        }
コード例 #9
0
ファイル: PluginBase.cs プロジェクト: JerryBian/PhotonSample
 /// <summary>
 /// Calls info.Continue(). Override to change.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 public virtual void OnCloseGame(ICloseGameCallInfo info)
 {
     System.Diagnostics.Debug.Assert(this.PluginHost != null);
     info.Continue();
 }