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();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
 /// <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();
 }
Esempio n. 5
0
 /// <summary>
 /// Calls info.Continue
 /// </summary>
 /// <param name="info"></param>
 public void OnCloseGame(ICloseGameCallInfo info)
 {
     info.Continue();
 }
Esempio n. 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();
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Calls info.Continue
 /// </summary>
 /// <param name="info"></param>
 public void OnCloseGame(ICloseGameCallInfo info)
 {
     info.Continue();
 }
Esempio n. 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();
            }
        }
Esempio n. 9
0
 /// <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();
 }