Beispiel #1
0
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            ++this.CallsCount;

            try
            {
                this.CheckIRaiseEventCallInfo(info);
                this.CheckBeforeOnRaiseEvent(info);
            }
            catch (Exception e)
            {
                info.Fail(e.ToString());
                return;
            }

            try
            {
                base.OnRaiseEvent(info);
                this.CheckAfterOnRaiseEvent(info);
            }
            catch (Exception e)
            {
                this.PluginHost.BroadcastErrorInfoEvent(e.ToString(), info);
            }
        }
Beispiel #2
0
        private void CheckWord(IRaiseEventCallInfo info)
        {
            string RecvdMessage = Encoding.Default.GetString((byte[])info.Request.Data);

            string       sql = "SELECT word FROM eng_words WHERE word=@answer";
            MySqlCommand cmd = new MySqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("@answer", RecvdMessage);

            using (MySqlDataReader result = cmd.ExecuteReader())
            {
                string ReturnMessage = "";
                if (result.HasRows)
                {
                    ReturnMessage = "success";
                }
                else
                {
                    ReturnMessage = "fail";
                }

                this.PluginHost.BroadcastEvent(target: ReciverGroup.All,
                                               senderActor: 0,
                                               targetGroup: 0,
                                               data: new Dictionary <byte, object>()
                {
                    { (byte)245, ReturnMessage }
                },
                                               evCode: info.Request.EvCode,
                                               cacheOp: 0);
            }
        }
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            try
            {
                var data = (Hashtable) info.Request.Data;
                var customObj = (CustomPluginType) data[0];
                Assert.AreEqual(1, customObj.byteField);
                Assert.AreEqual(2, customObj.intField);
                Assert.AreEqual("3", customObj.stringField);

                customObj.byteField = 2;
                customObj.intField = 3;
                customObj.stringField = "4";

                var d = new Dictionary<byte, object>
                {
                    {0, customObj},
                };

                this.BroadcastEvent(123, d);
            }
            catch (Exception e)
            {
                this.PluginHost.BroadcastErrorInfoEvent(e.ToString());
                return;
            }
            base.OnRaiseEvent(info);
        }
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            base.OnRaiseEvent(info);

            var raiseEventRequest = info.Request;
            var url = this.gameEventUrl;

            if (raiseEventRequest.HttpForward && !string.IsNullOrEmpty(url))
            {
                var state = WebFlags.ShouldSendState(info.Request.WebFlags) ? this.GetGameState() : null;

                this.PostJsonRequest(
                    url,
                    new WebhooksRequest
                {
                    Type       = "Event",
                    GameId     = this.PluginHost.GameId,
                    AppId      = this.AppId,
                    AppVersion = this.AppVersion,
                    Region     = this.Region,
                    UserId     = info.UserId,
                    Nickname   = info.Nickname,
                    ActorNr    = info.ActorNr,
                    Data       = raiseEventRequest.Data,
                    State      = state,
                    AuthCookie = WebFlags.ShouldSendAuthCookie(info.Request.WebFlags) ? info.AuthCookie : null,
                    EvCode     = raiseEventRequest.EvCode,
                },
                    this.LogIfFailedCallback,
                    null,
                    callAsync: !WebFlags.ShouldSendSync(info.Request.WebFlags));
            }
        }
Beispiel #5
0
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            try
            {
                var data      = (Hashtable)info.Request.Data;
                var customObj = (CustomPluginType)data[0];
                Assert.AreEqual(1, customObj.byteField);
                Assert.AreEqual(2, customObj.intField);
                Assert.AreEqual("3", customObj.stringField);

                customObj.byteField   = 2;
                customObj.intField    = 3;
                customObj.stringField = "4";

                var d = new Dictionary <byte, object>
                {
                    { 0, customObj },
                };

                this.BroadcastEvent(123, d);
            }
            catch (Exception e)
            {
                this.PluginHost.BroadcastErrorInfoEvent(e.ToString());
                return;
            }
            base.OnRaiseEvent(info);
        }
Beispiel #6
0
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            var res = this.CheckPreConditions(info);

            if (!string.IsNullOrEmpty(res))
            {
                info.Fail(res);
                return;
            }
            try
            {
                base.OnRaiseEvent(info);
            }
            catch (Exception e)
            {
                this.PluginHost.BroadcastErrorInfoEvent(e.ToString(), info);
                return;
            }

            res = this.CheckPostConditions(info);
            if (!string.IsNullOrEmpty(res))
            {
                this.PluginHost.BroadcastErrorInfoEvent(res, info);
            }
        }
Beispiel #7
0
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            if (1 == info.Request.EvCode)
            {
                string       playerName = Encoding.Default.GetString((byte[])info.Request.Data);
                string       sql        = "INSERT INTO users (name, date_created) VALUES ('" + playerName + "', now())";
                MySqlCommand cmd        = new MySqlCommand(sql, conn);
                cmd.ExecuteNonQuery();
                ++this.CallsCount;
                int    cnt           = this.CallsCount;
                string ReturnMessage = playerName + " clicked the button. Now the count is " + cnt.ToString();
                this.PluginHost.BroadcastEvent(target: ReciverGroup.All,
                                               senderActor: 0,
                                               targetGroup: 0,

                                               evCode: info.Request.EvCode,
                                               data: new Dictionary <byte, object>()
                {
                    {
                        (byte)245, ReturnMessage
                    }
                },

                                               cacheOp: 0);
            }
        }
        public void UpdateFriendsDatabase(IRaiseEventCallInfo info)
        {               //Use this to update data in friends table
            string packetData         = Encoding.Default.GetString((byte[])info.Request.Data);
            int    relationshipStatus = 0;

            if (info.Request.EvCode == (byte)EVENT_CODES.EV_ACCEPT_FRIEND)
            {
                relationshipStatus = 1;
            }
            if (info.Request.EvCode == (byte)EVENT_CODES.EV_DECLINE_FRIEND)
            {
                relationshipStatus = 2;
            }

            string sql      = "SELECT name_friender FROM friends WHERE name_friendee = '" + PacketDecoder.Instance.GetStringFromString(packetData, "NameFriendee") + "' AND relationship_status = 0";
            string friender = ConnectToMySQL(sql, false);

            DisconnectFromMySQL();

            sql = "UPDATE friends SET relationship_status = " + relationshipStatus + " WHERE name_friender = '" + friender + "' AND name_friendee = '" + PacketDecoder.Instance.GetStringFromString(packetData, "NameFriendee") + "'";
            ConnectToMySQL(sql, true);
            DisconnectFromMySQL();

            //Now time to update the other party
            if (relationshipStatus == 1)
            {
                InsertFriendsDatabase(PacketDecoder.Instance.GetStringFromString(packetData, "NameFriendee"), friender);
            }
            else if (relationshipStatus == 2)
            {
                DeleteFriendsDatabase(friender, PacketDecoder.Instance.GetStringFromString(packetData, "NameFriendee"));
            }
        }
        /// <summary>
        /// Called when flag is toggled
        /// </summary>
        /// <param name="info"></param>
        protected override void OnToggleFlag(IRaiseEventCallInfo info)
        {
            PluginHost.LogError("SetFlag");

            Dictionary <byte, object> data = info.Request.Data as Dictionary <byte, object>;

            int y = (int)data[0];
            int x = (int)data[1];

            if (board.IsFlag(y, x) || board.IsReveald(y, x))
            {
                return;                                              //Can not remove flag
            }
            if (board.IsMine(y, x))
            {
                board.ToggleFlag(y, x);
            }

            if (board.IsMine(y, x))
            {
                BroadcastEvent((byte)Event.ReceiveToggleFlag, new Dictionary <byte, object>()
                {
                    { (byte)0, y }, { (byte)1, x }, { (byte)2, board.IsFlag(y, x) }
                });
            }
            else
            {
                OpenTile(y, x, board.GetTile(y, x));
            }

            scoreManager.AddPoints(turnManager.Actors.Find(a => a.ActorNr == info.ActorNr), board.IsMine(y, x) ? 5 : -5);
        }
Beispiel #10
0
        private string CheckPostConditions(IRaiseEventCallInfo info)
        {
            var game = (HiveGame)this.PluginHost;

            if (info.Request.EvCode == 1)
            {
                var exectedCount = (int)((Hashtable)info.Request.Data)[0];
                var slice        = game.EventCache.Slice;
                if (exectedCount != game.EventCache.GetSliceSize(slice))
                {
                    return(string.Format("Slice {0} does not contain expected count ({1}) of events. It has {2}",
                                         slice, exectedCount, game.EventCache.GetSliceSize(slice)));
                }
            }
            else if (info.Request.EvCode == 2)
            {
                var expectedCount = (int)((Hashtable)info.Request.Data)[0];
                if (expectedCount != game.EventCache.Count)
                {
                    return(string.Format("Expected slices count = {0}. but it was {1}", expectedCount, game.EventCache.Count));
                }
            }
            else if (info.Request.EvCode == 3)
            {
                var expectedSlice = (int)((Hashtable)info.Request.Data)[0];
                if (expectedSlice != game.EventCache.Slice)
                {
                    return(string.Format("Unexpected slice index {0}. Expected is {1}", game.EventCache.Slice, expectedSlice));
                }
            }
            return(string.Empty);
        }
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            var request = new HttpRequest
            {
                Url       = "https://httpbin.org/response-headers",
                UserState = info,
                Method    = info.Request.EvCode == 1 ? "GET" : "POST",
                Callback  = this.Callback
            };

            if (this.PluginHost.GameId.Contains("OldHttp"))
            {
#pragma warning disable CS0612 // Type or member is obsolete
                PluginHost.HttpRequest(request);
#pragma warning restore CS0612 // Type or member is obsolete

                base.OnRaiseEvent(info);
            }
            else
            {
                PluginHost.HttpRequest(request, info);

                if (this.PluginHost.GameId.Contains("Async"))
                {
                    base.OnRaiseEvent(info);
                }
            }
        }
        //Sends out all the Players that are connected
        public void SendListOfPlayers(IRaiseEventCallInfo info)
        {
            if (ConnectedPlayers.Count > 0)
            {
                Player requestingClient = null;
                try
                {
                    requestingClient = (Player)PacketDecoder.Instance.DecodePlayer((byte[])info.Request.Data);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }

                if (requestingClient != null)
                {
                    foreach (Player player in ConnectedPlayers)
                    {
                        player.SetPacketTarget(requestingClient.GetPacketTarget());
                        this.PluginHost.BroadcastEvent(target: ReciverGroup.All, senderActor: 0, targetGroup: 0, evCode: (byte)EVENT_CODES.EV_LISTALLUSERS, data: new Dictionary <byte, object>()
                        {
                            { (byte)245, player }
                        }, cacheOp: 0);
                    }
                }
            }
        }
Beispiel #13
0
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            try
            {
                base.OnRaiseEvent(info);
            }
            catch (Exception e)
            {
                this.PluginHost.BroadcastErrorInfoEvent(e.ToString(), info);
                return;
            }

            switch (info.Request.EvCode)
            {
            case B_Check_Data:
            {
                CheckWord(info);
            }
            break;

            case B_Send_Word:
            {
                SendWordToOpp(info);
            }
            break;

            default:
                break;
            }
        }
 private string CheckPostConditions(IRaiseEventCallInfo info)
 {
     var game = (HiveGame)this.PluginHost;
     if (info.Request.EvCode == 1)
     {
         var exectedCount = (int) ((Hashtable) info.Request.Data)[0];
         var slice = game.EventCache.Slice;
         if (exectedCount != game.EventCache.GetSliceSize(slice))
         {
             return string.Format("Slice {0} does not contain expected count ({1}) of events. It has {2}",
                 slice, exectedCount, game.EventCache.GetSliceSize(slice));
         }
     }
     else if (info.Request.EvCode == 2)
     {
         var expectedCount = (int)((Hashtable)info.Request.Data)[0];
         if (expectedCount != game.EventCache.Count)
         {
             return string.Format("Expected slices count = {0}. but it was {1}", expectedCount, game.EventCache.Count);
         }
     }
     else if (info.Request.EvCode == 3)
     {
         var expectedSlice = (int)((Hashtable)info.Request.Data)[0];
         if (expectedSlice != game.EventCache.Slice)
         {
             return string.Format("Unexpected slice index {0}. Expected is {1}", game.EventCache.Slice, expectedSlice);
         }
     }
     return string.Empty;
 }
        /// <summary>
        /// Called when tile is opened
        /// </summary>
        /// <param name="info"></param>
        protected override void OnOpen(IRaiseEventCallInfo info)
        {
            Dictionary <byte, object> data = info.Request.Data as Dictionary <byte, object>;

            int y   = (int)data[0];
            int x   = (int)data[1];
            int val = board.GetTile(y, x);

            PluginHost.LogError(string.Format("y: {0} , x: {1} , val: {2} , IsIsReveald: {3} ", y, x, val, board.IsReveald(y, x)));

            if (!board.IsReveald(y, x))
            {
                OpenTile(y, x, val);
                if (!board.IsFlag(y, x))
                {
                    scoreManager.AddPoints(turnManager.Actors.Find(a => a.ActorNr == info.ActorNr), val == 10 ? -5 : 3);
                }
            }
            else
            if (TryOpenRest(y, x))
            {
                scoreManager.AddPoints(turnManager.Actors.Find(a => a.ActorNr == info.ActorNr), 2);
            }

            if (board.CheckIfComplete())
            {
                EndGame();
            }
        }
Beispiel #16
0
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            Loger.LogTagFormat(Loger.TagPlugin, "OnRaiseEvent===============BEGIN");
            Loger.LogTagFormat(Loger.TagPlugin, info.ToStr());

            base.OnRaiseEvent(info);
            Loger.LogTagFormat(Loger.TagPlugin, "OnRaiseEvent---------------END");
        }
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            if (info.Request.EvCode == 0)
            {
                base.OnRaiseEvent(info);
            }
            else if (info.Request.EvCode == 1)
            {
                info.Defer();
            }
            else if (info.Request.EvCode == 2)
            {
                info.Cancel();
            }
            else if (info.Request.EvCode == 3)
            {
                info.Fail();
                this.PluginHost.BroadcastErrorInfoEvent("We called fail method");
            }
            else if (info.Request.EvCode == 4)
            {
                throw new Exception("Event 4 exception");
            }
            else if (info.Request.EvCode == 5)
            {
                var request = new HttpRequest
                {
                    Async = true,
                    Callback = HttpCallbackWithException,
                    Url = "http://photon.webscript.io/auth-demo/",
                };

                this.PluginHost.HttpRequest(request);
                info.Defer();
            }
            else if (info.Request.EvCode == 6)
            {
                var request = new HttpRequest
                {
                    Async = false,
                    Callback = HttpCallbackWithException,
                    Url = "http://photon.webscript.io/auth-demo/",
                };

                this.PluginHost.HttpRequest(request);
                info.Continue();
            }
            else if (info.Request.EvCode == 7)
            {
                this.timer = this.PluginHost.CreateOneTimeTimer(this.TimerAction, 100);
                info.Defer();
            }
            else if (info.Request.EvCode == 8)
            {
                this.timer = this.PluginHost.CreateTimer(this.TimerAction, 100, 100);
                info.Defer();
            }
        }
Beispiel #18
0
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            if (info.Request.EvCode == 0)
            {
                base.OnRaiseEvent(info);
            }
            else if (info.Request.EvCode == 1)
            {
                info.Defer();
            }
            else if (info.Request.EvCode == 2)
            {
                info.Cancel();
            }
            else if (info.Request.EvCode == 3)
            {
                info.Fail();
                this.PluginHost.BroadcastErrorInfoEvent("We called fail method");
            }
            else if (info.Request.EvCode == 4)
            {
                throw new Exception("Event 4 exception");
            }
            else if (info.Request.EvCode == 5)
            {
                var request = new HttpRequest
                {
                    Async    = true,
                    Callback = HttpCallbackWithException,
                    Url      = "http://photon.webscript.io/auth-demo/",
                };

                this.PluginHost.HttpRequest(request);
                info.Defer();
            }
            else if (info.Request.EvCode == 6)
            {
                var request = new HttpRequest
                {
                    Async    = false,
                    Callback = HttpCallbackWithException,
                    Url      = "http://photon.webscript.io/auth-demo/",
                };

                this.PluginHost.HttpRequest(request);
                info.Continue();
            }
            else if (info.Request.EvCode == 7)
            {
                this.timer = this.PluginHost.CreateOneTimeTimer(this.TimerAction, 100);
                info.Defer();
            }
            else if (info.Request.EvCode == 8)
            {
                this.timer = this.PluginHost.CreateTimer(this.TimerAction, 100, 100);
                info.Defer();
            }
        }
Beispiel #19
0
 public override void OnRaiseEvent(IRaiseEventCallInfo info)
 {
     this.PluginHost.HttpRequest(new HttpRequest
     {
         Url      = "WrongUrl",
         Callback = this.HttpRequestCallback
     }, info);
     base.OnRaiseEvent(info);
 }
 public override void OnRaiseEvent(IRaiseEventCallInfo info)
 {
     this.PluginHost.HttpRequest(new HttpRequest
     {
         Url = "WrongUrl",
         Callback = this.HttpRequestCallback
     });
     base.OnRaiseEvent(info);
 }
        public void InsertUsersDatabase(IRaiseEventCallInfo info)
        {
            string packetData = Encoding.Default.GetString((byte[])info.Request.Data);

            string sql = "INSERT INTO users (name, password, date_created) VALUES ('" + PacketDecoder.Instance.GetStringFromString(packetData, "Name") + "', '" + PacketDecoder.Instance.GetStringFromString(packetData, "Password") + "', now())";

            ConnectToMySQL(sql, true);
            DisconnectFromMySQL();
        }
        public void UpdateUsersDatabase(IRaiseEventCallInfo info)
        {
            string packetData = Encoding.Default.GetString((byte[])info.Request.Data);

            string sql = "UPDATE users SET password = '******', prefab_path = '" + PacketDecoder.Instance.GetStringFromString(packetData, "PrefabPath") + "', last_position = '" + PacketDecoder.Instance.GetVectorFromString(packetData, "LastPosition") + "', last_rotation = '" + PacketDecoder.Instance.GetQuaternionFromString(packetData, "LastRotation") + "' WHERE name = '" + PacketDecoder.Instance.GetStringFromString(packetData, "Name") + "'";

            ConnectToMySQL(sql, true);
            DisconnectFromMySQL();
        }
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            if (info.Request.EvCode == 0)
            {
                base.OnRaiseEvent(info);
            }
            else if (info.Request.EvCode == 1)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                info.Defer();
#pragma warning restore CS0618 // Type or member is obsolete
            }
            else if (info.Request.EvCode == 2)
            {
                info.Cancel();
            }
            else if (info.Request.EvCode == 3)
            {
                info.Fail();
                this.PluginHost.BroadcastErrorInfoEvent("We called fail method");
            }
            else if (info.Request.EvCode == 4)
            {
                throw new Exception("Event 4 exception");
            }
            else if (info.Request.EvCode == 5)
            {
                var request = new HttpRequest
                {
                    Async    = true,
                    Callback = HttpCallbackWithException,
                    Url      = "https://wt-e4c18d407aa73a40e4182aaf00a2a2eb-0.run.webtask.io/auth/auth-demo/",
                };

                this.PluginHost.HttpRequest(request, info);
            }
            else if (info.Request.EvCode == 6)
            {
                var request = new HttpRequest
                {
                    Async    = false,
                    Callback = HttpCallbackWithException,
                    Url      = "https://wt-e4c18d407aa73a40e4182aaf00a2a2eb-0.run.webtask.io/auth/auth-demo/",
                };

                this.PluginHost.HttpRequest(request, info);
            }
            else if (info.Request.EvCode == 7)
            {
                this.timer = this.PluginHost.CreateOneTimeTimer(info, this.TimerAction, 100);
            }
            else if (info.Request.EvCode == 8)
            {
                this.timer = this.PluginHost.CreateTimer(this.TimerAction, 100, 100);
            }
        }
 public void SendEvent(IRaiseEventCallInfo info, object ReturnMessage, List <int> targets)
 {
     this.PluginHost.BroadcastEvent(recieverActors: targets, senderActor: 0, evCode: info.Request.EvCode, data: new Dictionary <byte, object>()
     {
         {
             (byte)245, ReturnMessage
         }
     },
                                    cacheOp: 0);
 }
Beispiel #25
0
 public override void OnRaiseEvent(IRaiseEventCallInfo info)
 {
     base.OnRaiseEvent(info);
     var data = (Hashtable) info.Request.Data;
     if ((bool) data[0])
     {
         //lets ban
         this.PluginHost.RemoveActor((int)data[1], RemoveActorReason.Banned, "bb");
     }
 }
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
#pragma warning disable CS0612 // Type or member is obsolete
            this.PluginHost.HttpRequest(new HttpRequest
            {
                Url      = "WrongUrl",
                Callback = this.HttpRequestCallback
            });
#pragma warning restore CS0612 // Type or member is obsolete
            base.OnRaiseEvent(info);
        }
 public void BroadcastEvent(IRaiseEventCallInfo info, string ReturnMessage)
 {
     this.PluginHost.BroadcastEvent(target: ReciverGroup.All, senderActor: 0, targetGroup: 0, data: new Dictionary <byte, object>()
     {
         {
             (byte)245, ReturnMessage
         }
     },
                                    evCode: info.Request.EvCode,
                                    cacheOp: 0);
 }
Beispiel #28
0
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            base.OnRaiseEvent(info);
            var data = (Hashtable)info.Request.Data;

            if ((bool)data[0])
            {
                //lets ban
                this.PluginHost.RemoveActor((int)data[1], RemoveActorReason.Banned, "bb");
            }
        }
Beispiel #29
0
 private void CheckBeforeOnRaiseEvent(IRaiseEventCallInfo info)
 {
     if (info.Request.EvCode == 1)
     {
         info.Request.Cache = (byte)CacheOperation.DoNotCache;
     }
     else if (info.Request.EvCode == 3)
     {
         info.Request.Cache = (byte)CacheOperation.SliceIncreaseIndex;
     }
 }
 public override void OnRaiseEvent(IRaiseEventCallInfo info)
 {
     if (info.Request.EvCode == 1)
     {
         this.PluginHost.BroadcastEvent(new[] { 2, 25 }, 0, 1, null, 0);
     }
     else if (info.Request.EvCode == 2)
     {
         this.PluginHost.BroadcastEvent(new[] { 2, 3 }, 0, 1, null, 0);
     }
     base.OnRaiseEvent(info);
 }
 public override void OnRaiseEvent(IRaiseEventCallInfo info)
 {
     if (info.Request.EvCode == 1)
     {
         this.PluginHost.BroadcastEvent(new[] { 2, 25 }, 0, 1, null, 0);
     }
     else if (info.Request.EvCode == 2)
     {
         this.PluginHost.BroadcastEvent(new[] { 2, 3 }, 0, 1, null, 0);
     }
     base.OnRaiseEvent(info);
 }
Beispiel #32
0
 public void OnRaiseEvent(IRaiseEventCallInfo info)
 {
     try
     {
         this.Plugin.OnRaiseEvent(info);
         this.StrictModeCheck(info);
     }
     catch (Exception e)
     {
         this.ExceptionHanlder(info, e);
     }
 }
Beispiel #33
0
        public static string ToStr(this IRaiseEventCallInfo info)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("IRaiseEventCallInfo =========== BEGIN");
            builder.AppendLine(string.Format("IRaiseEventCallInfo.ActorNr={0}", info.ActorNr));
            builder.AppendLine(((ITypedCallInfo <IRaiseEventRequest>)info).ToStr <IRaiseEventRequest>());
            builder.AppendLine(((ICallInfo)info).ToStr());

            builder.AppendLine("IRaiseEventCallInfo ----------- END");
            return(builder.ToString());
        }
 public override void OnRaiseEvent(IRaiseEventCallInfo info)
 {
     if (info.Request.EvCode == 1)
     {
         this.PluginHost.SetProperties(0, new System.Collections.Hashtable
         {
             { GameParameters.PlayerTTL, 2000 },
             { GameParameters.EmptyRoomTTL, 2000 }
         }, null, false);
     }
     base.OnRaiseEvent(info);
 }
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            base.OnRaiseEvent(info);


            var json       = (string)((Hashtable)info.Request.Data)[0];
            var parsedJson = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);

            this.PluginHost.BroadcastEvent(ReciverGroup.All, 0, 0, 123, new Dictionary <byte, object> {
                { 1, parsedJson },
            }, CacheOperations.DoNotCache);
        }
Beispiel #36
0
 /// <summary>
 /// Plugin callback when Op RaiseEvent is called.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 void IGamePlugin.OnRaiseEvent(IRaiseEventCallInfo info)
 {
     try
     {
         this.OnRaiseEvent(info);
         this.StrictModeCheck(info);
     }
     catch (Exception e)
     {
         ((IGamePlugin)this).ReportError(ErrorCodes.UnhandledException, e);
         CallFailSafe(info, e.ToString());
     }
 }
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            var res = this.CheckPreConditions(info);
            if (!string.IsNullOrEmpty(res))
            {
                info.Fail(res);
                return;
            }
            try
            {
                base.OnRaiseEvent(info);
            }
            catch (Exception e)
            {
                this.PluginHost.BroadcastErrorInfoEvent(e.ToString(), info);
                return;
            }

            res = this.CheckPostConditions(info);
            if (!string.IsNullOrEmpty(res))
            {
                this.PluginHost.BroadcastErrorInfoEvent(res, info);
            }
        }
Beispiel #38
0
 public override void OnRaiseEvent(IRaiseEventCallInfo info)
 {
     this.onRaiseEvent.Set();
     info.Continue();
 }
Beispiel #39
0
 /// <summary>
 /// Calls info.Continue(). Override to change.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 public virtual void OnRaiseEvent(IRaiseEventCallInfo info)
 {
     info.Continue();
 }
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            base.OnRaiseEvent(info);

            var raiseEventRequest = info.Request;
            var url = this.gameEventUrl;

            if (raiseEventRequest.HttpForward && !string.IsNullOrEmpty(url))
            {
                var state = WebFlags.ShouldSendState(info.Request.WebFlags) ? this.GetGameState() : null;

                this.PostJsonRequest(
                    url,
                    new WebhooksRequest
                    {
                        Type = "Event",
                        GameId = this.PluginHost.GameId,
                        AppId = this.AppId,
                        AppVersion = this.AppVersion,
                        Region = this.Region,
                        UserId = info.UserId,
                        Nickname = info.Nickname,
                        ActorNr = info.ActorNr,
                        Data = raiseEventRequest.Data,
                        State = state,
                        AuthCookie = WebFlags.ShouldSendAuthCookie(info.Request.WebFlags) ? info.AuthCookie : null,
                        EvCode =  raiseEventRequest.EvCode,
                    },
                    this.LogIfFailedCallback,
                    null,
                    callAsync: !WebFlags.ShouldSendSync(info.Request.WebFlags));
            }
        }
 public override void OnRaiseEvent(IRaiseEventCallInfo info)
 {
     this.GameStateCheck(info);
     base.OnRaiseEvent(info);
 }
Beispiel #42
0
 /// <summary>
 /// Calls info.Fail
 /// </summary>
 /// <param name="info"></param>
 public void OnRaiseEvent(IRaiseEventCallInfo info)
 {
     info.Fail(this.errorMsg);
 }
 private void GameStateCheck(IRaiseEventCallInfo info)
 {
 }
 private string CheckPreConditions(IRaiseEventCallInfo info)
 {
     return string.Empty;
 }
Beispiel #45
0
 /// <summary>
 /// Plugin callback when Op RaiseEvent is called.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 void IGamePlugin.OnRaiseEvent(IRaiseEventCallInfo info)
 {
     try
     {
         this.OnRaiseEvent(info);
         this.StrictModeCheck(info);
     }
     catch (Exception e)
     {
         ((IGamePlugin)this).ReportError(ErrorCodes.UnhandledException, e);
         CallFailSafe(info, e.ToString());
     }
 }