Exemple #1
0
 protected virtual void RaiseGameStartsAtRecieved(GameStartsAtMessage message)
 {
     if (GameStartsAtRecieved != null)
     {
         GameStartsAtRecieved(this, new MessageEventArgs <GameStartsAtMessage>(message));
     }
 }
Exemple #2
0
        public bool SendGameStartsAt(GameStartsAtMessage message)
        {
            EnsureUsername(message);

            if (client.IsConnected && client.IsSubscribed(Channel))
            {
                string data = System.Web.HttpUtility.UrlEncode(JsonConvert.SerializeObject(message));
                client.Send(Channel, data);
            }
            else
            {
                throw new Exception("not connected. Call Join Game first");
            }
            return(true);
        }
Exemple #3
0
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                JToken jObject = JToken.ReadFrom(reader);
                var    type    = jObject["MessageType"].ToString();

                BaseMessage message;

                switch (type)
                {
                case "FugitiveDistance":
                    message = new FugitiveDistanceMessage();
                    break;

                case "FugitiveLocation":
                    message = new FugitiveLocationMessage();
                    break;

                case "GameStartsAt":
                    message = new GameStartsAtMessage();
                    break;

                case "HelloMessage":
                    message = new HelloMessage();
                    break;

                case "Surrender":
                    message = new SurrenderMessage();
                    break;

                case "CaughtMessage":
                    message = new CaughtMessage();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                serializer.Populate(jObject.CreateReader(), message);

                return(message);
            }