public override void OnCloseGame(ICloseGameCallInfo info)
        {
            base.OnCloseGame(info);
            var state = this.PluginHost.GetSerializableGameState();

            gameStates[this.PluginHost.GameId] = state;
        }
Beispiel #2
0
        public override void OnCloseGame(ICloseGameCallInfo info)
        {
            base.OnCloseGame(info);
            var state = this.PluginHost.GetSerializableGameState();

            WriteGameStateToFile(this.PluginHost.GameId, state);
        }
Beispiel #3
0
        public override void OnCloseGame(ICloseGameCallInfo info)
        {
            Loger.LogTagFormat(Loger.TagPlugin, "OnCloseGame===============BEGIN");
            Loger.LogTagFormat(Loger.TagPlugin, info.ToStr());

            base.OnCloseGame(info);
            Loger.LogTagFormat(Loger.TagPlugin, "OnCloseGame---------------END");
        }
Beispiel #4
0
 public void OnCloseGame(ICloseGameCallInfo info)
 {
     try
     {
         this.Plugin.OnCloseGame(info);
         this.StrictModeCheck(info);
     }
     catch (Exception e)
     {
         this.ExceptionHanlder(info, e);
     }
 }
Beispiel #5
0
        public static string ToStr(this ICloseGameCallInfo info)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("ICloseGameCallInfo =========== BEGIN");
            builder.AppendLine(string.Format("ICloseGameCallInfo.ActorCount={0}", info.ActorCount));
            builder.AppendLine(string.Format("ICloseGameCallInfo.FailedOnCreate={0}", info.FailedOnCreate));
            builder.AppendLine(((ITypedCallInfo <ICloseRequest>)info).ToStr <ICloseRequest>());
            builder.AppendLine(((ICallInfo)info).ToStr());

            builder.AppendLine("ICloseGameCallInfo ----------- END");
            return(builder.ToString());
        }
Beispiel #6
0
 /// <summary>
 /// Plugin callback called when info.Continue() is called inside <see cref="IGamePlugin.BeforeCloseGame"/>.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 void IGamePlugin.OnCloseGame(ICloseGameCallInfo info)
 {
     try
     {
         this.OnCloseGame(info);
         this.StrictModeCheck(info);
     }
     catch (Exception e)
     {
         ((IGamePlugin)this).ReportError(ErrorCodes.UnhandledException, e);
         CallFailSafe(info, e.ToString());
     }
 }
        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();
        }
Beispiel #8
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();
        }
Beispiel #9
0
        public override void OnCloseGame(ICloseGameCallInfo info)
        {
            ++this.CallsCount;

            try
            {
                this.CheckICloseGameCallInfo(info);
                this.CheckBeforeOnCloseGame();
            }
            catch (Exception e)
            {
                info.Fail(e.ToString());
                return;
            }
            try
            {
                base.OnCloseGame(info);
                this.CheckAfterOnCloseGame();
            }
            catch (Exception e)
            {
                this.PluginHost.BroadcastErrorInfoEvent(e.ToString(), info);
            }
        }
Beispiel #10
0
 /// <summary>
 /// Calls info.Continue
 /// </summary>
 /// <param name="info"></param>
 public void OnCloseGame(ICloseGameCallInfo info)
 {
     info.Continue();
 }
        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();
            }
        }
Beispiel #12
0
 public override void OnCloseGame(ICloseGameCallInfo info)
 {
     base.OnCloseGame(info);
 }
        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();
            }
        }
 public override void OnCloseGame(ICloseGameCallInfo info)
 {
     base.OnCloseGame(info);
     var state = this.PluginHost.GetSerializableGameState();
     gameStates[this.PluginHost.GameId] = state;
 }
 public override void OnCloseGame(ICloseGameCallInfo info)
 {
     Thread.Sleep(2000);
     base.OnCloseGame(info);
 }
Beispiel #16
0
 /// <summary>
 /// Plugin callback called when info.Continue() is called inside <see cref="IGamePlugin.BeforeCloseGame"/>.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 void IGamePlugin.OnCloseGame(ICloseGameCallInfo info)
 {
     this.OnCloseGame(info);
 }
Beispiel #17
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();
 }
Beispiel #18
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();
        }
Beispiel #19
0
 /// <summary>
 /// Calls info.Continue
 /// </summary>
 /// <param name="info"></param>
 public void OnCloseGame(ICloseGameCallInfo info)
 {
     info.Continue();
 }
        public override void OnCloseGame(ICloseGameCallInfo info)
        {
            this.httpListener.Stop();

            base.OnCloseGame(info);
        }
Beispiel #21
0
 private void CheckICloseGameCallInfo(ICloseGameCallInfo info)
 {
     this.CheckBaseInfo(info);
     Assert.AreEqual(0, info.ActorCount);
     Assert.AreEqual(0, info.Request.EmptyRoomTTL);
 }
Beispiel #22
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();
 }
Beispiel #23
0
 public override void OnCloseGame(ICloseGameCallInfo info)
 {
     this.MethodBody(info, MethodBase.GetCurrentMethod().Name);
 }
 public override void OnCloseGame(ICloseGameCallInfo info)
 {
     Thread.Sleep(2000);
     base.OnCloseGame(info);
 }
Beispiel #25
0
 /// <summary>
 /// Plugin callback called when info.Continue() is called inside <see cref="IGamePlugin.BeforeCloseGame"/>.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 void IGamePlugin.OnCloseGame(ICloseGameCallInfo info)
 {
     try
     {
         this.OnCloseGame(info);
         this.StrictModeCheck(info);
     }
     catch (Exception e)
     {
         ((IGamePlugin)this).ReportError(ErrorCodes.UnhandledException, e);
         CallFailSafe(info, e.ToString());
     }
 }