Esempio n. 1
0
 public static void AssertAllOfType(this JsonMessageLog log, GameMessageType messageType)
 {
     foreach (dynamic msg in log.Messages)
     {
         Assert.IsTrue(msg.type == messageType.ToString());
     }
 }
Esempio n. 2
0
    public void SendGameMessage <T>(GameMessageType type, T t)
    {
        switch (type)
        {
        case GameMessageType.MESSAGE_HERO_ATTACK:

            break;

        case GameMessageType.MESSAGE_HERO_DIE:
            break;

        case GameMessageType.MESSAGE_HERO_HURT:
            break;

        case GameMessageType.MESSAGE_HERO_IDLE:
            break;

        case GameMessageType.MESSAGE_HERO_WALK:
            break;

        case GameMessageType.MESSAGE_MONSTER_ATTACK:

            break;

        case GameMessageType.MESSAGE_MONSTER_DIE:
            break;

        case GameMessageType.MESSAGE_MONSTER_HURT:
            break;

        case GameMessageType.MESSAGE_MONSTER_WALK:
            break;
        }
    }
        private void ProcessMessage(NetIncomingMessage msg)
        {
            try
            {
                GameMessageType m = (GameMessageType)msg.ReadByte();
                switch (m)
                {
                case GameMessageType.CharacterLocation:

                    break;

                default:
                    logger.Warn("Malformed message.  Invalid message type byte: " + (byte)m);
                    break;
                }
            }
            catch (Exception e)
            {
                logger.Warn(e, "Unknown processing Game Message");
            }
            finally
            {
                networkClient.Recycle(msg);
            }
        }
Esempio n. 4
0
 public Frame(int roomid, object data, MessageType messageType, GameMessageType gameMessageType)
 {
     RoomId      = roomid;
     Data        = data;
     MsgType     = messageType;
     GameMsgType = gameMessageType;
 }
Esempio n. 5
0
 public static void AssertAllOfType(this JsonMessageLog log, GameMessageType messageType)
 {
     foreach (dynamic msg in log.Messages)
     {
         Assert.IsTrue(msg.type == messageType.ToString());
     }
 }
Esempio n. 6
0
    private void Send(GameMessageType type, string innerMessage)
    {
        string message = JsonUtility.ToJson(new MessageWrapper(type, innerMessage, gameID, clientId: clientID, token: CurrentGame.Instance.ClientToken));

        messageBuffer.Enqueue(message);
        Send();
    }
Esempio n. 7
0
        private JsonObject BuildGameMessageJson(GameMessageType messageType, Action <dynamic> applyValues)
        {
            dynamic jsonObject = new JsonObject();

            jsonObject.type = messageType.ToString();
            jsonObject.body = new JsonObject();
            applyValues(jsonObject.body);
            return(jsonObject);
        }
Esempio n. 8
0
 public MessageWrapper(GameMessageType messageType, string message, string gameId, string token = null, string clientId = null)
 {
     this.eMessageType = messageType;
     this.message      = message;
     this.gameID       = gameId;
     this.token        = token;
     this.clientID     = clientId;
     this.messageType  = eMessageType.ToString();
 }
        private async Task SendGameMessage(GameMessageType msg)
        {
            await SendAsync(MessageFormat.Concat(MessageType.Game, msg));

            if (msg == GameMessageType.End)
            {
                CloseAllConnections();
                Game.status.State = GameState.End;
            }
        }
Esempio n. 10
0
    private static string LobbyIdJson(GameMessageType gameMessageType, string lobbyId)
    {
        var lobbyIdJson = new LobbyId()
        {
            lobbyId = lobbyId
        };
        var jsonString = JsonConvert.SerializeObject(lobbyIdJson);

        return(JsonCreator.RemoveSlash(JsonCreator.CreateJson(gameMessageType.ToString(), jsonString)));
    }
        public void SendMessage(String messageString, GameMessageType eGameMessageType)
        {
            if (_chatService.GetState() == TicTacToeXamarin.BluetoothService.STATE_CONNECTED &&
                messageString.Length > 0)
            {
                messageString += Convert.ToString((int)eGameMessageType) + COORDINATE_MESSAGE_SEPARATOR;

                byte[] bytes = Encoding.ASCII.GetBytes(messageString);
                _chatService.Write(bytes);
            }
        }
        private async Task SendGameOnlineMessage(GameMessageType msg)
        {
            var send_msg = MessageFormat.Concat(MessageType.Game, msg);

            await SendAsyncOnline(send_msg);

            if (msg == GameMessageType.End)
            {
                CloseAllConnections();
                Game.status.State = GameState.End;
            }
        }
        private GameMessageType GetGameMessageType(string readMessage)
        {
            GameMessageType gameMessageType           = GameMessageType.Unknown;
            int             valueIntOfGameMessageType = -1;

            string[] encodedCoordinateSpliArrayString = readMessage.Split(COORDINATE_MESSAGE_SEPARATOR);

            if (int.TryParse(encodedCoordinateSpliArrayString[3], out valueIntOfGameMessageType))
            {
                gameMessageType = (GameMessageType)valueIntOfGameMessageType;
            }

            return(gameMessageType);
        }
Esempio n. 14
0
        public void AddToOutgoingMessageQueue(GameMessageType opcode, object dataObject, List<Player> recipients)
        {
            if (recipients.Count > 0)
            {
                OutgoingGameMessageQueueItem item = new OutgoingGameMessageQueueItem();
                item.OperationCode = opcode;
                item.Data = m_slrSerializer.GetBytes(dataObject);
                //-- Disconnected list doesn't exist anymore
                //-- Filter from the disconnected list
                //item.Recipients = recipients - Table.DisconnectedPlayers;

                item.Recipients = recipients;
                m_qOutgoingQueue.Add(item);
            }
        }
Esempio n. 15
0
        private void ProcessGameMessage(NetIncomingMessage msg)
        {
            try
            {
                GameMessageType m = (GameMessageType)msg.ReadByte();
                switch (m)
                {
                case GameMessageType.PlayerDestination:
                    Byte playerId = msg.ReadByte();
                    if (playerId > maxClients)
                    {
                        logger.ConditionalTrace("Player with uniqueId " + msg.SenderConnection.RemoteUniqueIdentifier + " tried to move out of range player " + playerId);
                    }

                    if (msg.SenderConnection.RemoteUniqueIdentifier == players[playerId].UniqueId)
                    {
                        Point location;
                        location.x = msg.ReadInt32();
                        location.y = msg.ReadInt32();
                        players[playerId].UpdateDestination(location);
                    }
                    else
                    {
                        logger.ConditionalTrace("Player with uniqueId " + msg.SenderConnection.RemoteUniqueIdentifier + " tried to move non-owned player " + playerId);
                    }
                    break;

                case GameMessageType.CharacterLocation:
                    break;

                default:
                    console.WriteWarn("Malformed message.  Invalid message type byte: " + (byte)m);
                    break;
                }
            }
            catch (Exception e)
            {
                //console.WriteWarn(e, "Unknown processing Game Message");
            }
            finally
            {
                RecycleMessage(msg);
            }
        }
Esempio n. 16
0
        public async Task Answer(GameAnswer message, GameMessageType messageType = GameMessageType.RegularAnswer)
        {
            PlayerInfo playerInfo = await _players.GetById(message.PlayerId);

            _rabbitMqChannel.BasicPublish(
                _rabbitMqSettings.MessagesExchange,
                new MessagesRoutingKeyBuilder()
                .WithSocialNetwork(playerInfo.ReplyQueueName)
                .WithMessageType(messageType)
                .Build(),
                null,
                new MessageToSocialNetwork
            {
                Text           = message.Text,
                PlayerId       = message.PlayerId,
                Suggestions    = message.Suggestions,
                PlayerSocialId = playerInfo.SocialId
            }.EncodeObject()
                );
        }
Esempio n. 17
0
 public SendMessage(GameMessageType type, string message, string recipient)
     : base(Build(type, message, recipient))
 {
     this.type = type;
     this.message = message;
     this.recipient = recipient;
 }
Esempio n. 18
0
        public virtual void SendEnvelopeObjectToServer(GameMessageType messageType, byte[] innerData, List<IPEndPoint> receivers, RouteInfo routeInfo)
        {
            ServerEnvelopeObject envelope = new ServerEnvelopeObject();
            envelope.InnerOperationCode = (int)messageType;
            envelope.InnerData = innerData;
            envelope.SenderServerId = ServerId;
            envelope.RouteInfo = routeInfo;

            OutgoingMessage com = ServerMessageFormatter.CreateOutgoingMessage(
                (int)ServerMessageType.ReceiveForwardedMessageFromClient,
                Serializer.GetBytes(envelope),
                receivers);

            InternalOutgoingMessageQueue.Add(com);
        }
Esempio n. 19
0
 // Methods
 public SendMessage(byte[] data)
     : base(data)
 {
     this.type = (GameMessageType) BitConverter.ToUInt16(data, 1);
     this.message = ByteConverter.GetNullString(data, 3);
     if (this.type == GameMessageType.GameWhisper)
     {
     this.recipient = ByteConverter.GetNullString(data, 4 + this.message.Length);
     }
 }
Esempio n. 20
0
 public virtual void SendMessageToPlayers(GameMessageType messageType, byte[] data, List<string> players)
 {
     SendMessageToPlayers(messageType, data, ResolvePlayers(players));
 }
Esempio n. 21
0
 public void OutputLine(GameMessageType type, string line)
 {
     DedicatedLauncher.Singleton.EnqueueUxJob(delegate () {
         Window.Log(string.Format("[{0}] {1}", type, line));
     });
 }
Esempio n. 22
0
 public GameMessage(GameMessageType type, string message)
     : base(Build(type,message))
 {
     this.unitType = UnitType.NotApplicable;
     this.random = -1;
     this.messageType = type;
     this.playerName = null;
     this.message = message;
 }
 public JoinTableRequestHandler(GatewayNetworkManager2 manager, GameMessageType target)
     : base(manager, target)
 {
 }
Esempio n. 24
0
 // Methods
 public GameMessage(byte[] data)
     : base(data)
 {
     this.unitType = UnitType.NotApplicable;
     this.random = -1;
     this.messageType = (GameMessageType) ((ushort) BitConverter.ToInt16(data, 1));
     if (this.messageType == GameMessageType.OverheadMessage)
     {
         this.unitType = (UnitType) data[3];
         this.uid = BitConverter.ToUInt32(data, 4);
         this.random = BitConverter.ToUInt16(data, 8);
         this.message = ByteConverter.GetNullString(data, 11);
     }
     else
     {
         this.playerName = ByteConverter.GetNullString(data, 10);
         this.message = ByteConverter.GetNullString(data, 11 + this.playerName.Length);
     }
 }
Esempio n. 25
0
 public MessagesRoutingKeyBuilder WithMessageType(GameMessageType messageType) =>
 new MessagesRoutingKeyBuilder
 {
     SocialNetwork = SocialNetwork,
     MessageType   = messageType
 };
Esempio n. 26
0
            private bool ProcessGameMessage(string name,
							 GameMessageType type)
            {
                if (GameMessageEvent != null)
                    GameMessageEvent (this, name, type);
                return true;
            }
Esempio n. 27
0
 public GameMessage(GameMessageType type) : base((int)type)
 {
     m_messageType = type;
 }
Esempio n. 28
0
        public static byte[] Build(GameMessageType type, string message)
        {
            if ((message == null) || (message.Length == 0))
            {
                throw new ArgumentException("message");
            }

            byte[] Buffer = new byte[((12+1) + message.Length)];
            Buffer[0] = 0x26;
            Buffer[1] = (byte)type;
            Buffer[3] = 2;
            Buffer[9] = 5;
            int num2 = 0;
            int num3 = 11;

            while ((num2 < message.Length))
            {
                Buffer[num3 + num2] = (byte)message[num2];
                num2++;
            }

            return Buffer;
        }
Esempio n. 29
0
 public static byte[] Build(GameMessageType type, string charName, string message)
 {
     if ((charName == null) || (charName.Length == 0))
     {
         throw new ArgumentException("charName");
     }
     if ((message == null) || (message.Length == 0))
     {
         throw new ArgumentException("message");
     }
     byte[] buffer = new byte[(12 + charName.Length) + message.Length];
     buffer[0] = 0x26;
     buffer[1] = (byte)type;
     buffer[3] = 2;
     buffer[9] = 5;
     for (int i = 0; i < charName.Length; i++)
     {
         buffer[10 + i] = (byte)charName[i];
     }
     int num2 = 0;
     int num3 = 11 + charName.Length;
     while (num2 < message.Length)
     {
         buffer[num3 + num2] = (byte)message[num2];
         num2++;
     }
     return buffer;
 }
Esempio n. 30
0
 public GameMessage(UnitType type, uint uid, ushort random, string message)
     : base(Build(type, uid, random, message))
 {
     this.unitType = UnitType.NotApplicable;
     this.random = -1;
     this.messageType = GameMessageType.OverheadMessage;
     this.uid = uid;
     this.random = random;
     this.message = message;
 }
Esempio n. 31
0
 public static byte[] Build(GameMessageType type, string message, string recipient)
 {
     if ((message == null) || (message.Length == 0))
     {
     throw new ArgumentException();
     }
     int num = (recipient != null) ? recipient.Length : 0;
     byte[] buffer = new byte[(6 + message.Length) + num];
     buffer[0] = 0x15;
     buffer[1] = (byte) type;
     buffer[2] = (byte) (((byte) type) >> 8);
     for (int i = 0; i < message.Length; i++)
     {
     buffer[3 + i] = (byte) message[i];
     }
     if (num > 0)
     {
     num = 4 + message.Length;
     for (int j = 0; j < recipient.Length; j++)
     {
         buffer[num + j] = (byte) recipient[j];
     }
     }
     return buffer;
 }
Esempio n. 32
0
 public GameMessage getData(GameMessageType t)
 {
     return(data[(int)t]);
 }
Esempio n. 33
0
 /// <summary>
 /// 创建 GameMessage 对象
 /// </summary>
 /// <param name="type">游戏消息类型</param>
 /// <param name="message">消息内容</param>
 protected GameMessage(GameMessageType type, string message) : this(type, message, DateTime.UtcNow)
 {
 }
 public void OutputLine(GameMessageType type, string line)
 {
     Console.WriteLine("[{0}] {1}", type, line);
 }
Esempio n. 35
0
 private JsonObject BuildGameMessageJson(GameMessageType messageType, Action<dynamic> applyValues)
 {
     dynamic jsonObject = new JsonObject();
     jsonObject.type = messageType.ToString();
     jsonObject.body = new JsonObject();
     applyValues(jsonObject.body);
     return jsonObject;
 }
Esempio n. 36
0
 /// <summary>
 /// Creates network objects with given type. Note that network objects must have
 /// default constructors and must be registered to `GameMessageFactory`.
 /// </summary>
 /// <param name="type"></param>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public T CreateMessage <T>(GameMessageType type) where T : Message
 {
     return(_client.CreateMessage((int)type) as T);
 }
Esempio n. 37
0
        public virtual void SendMessageToPlayers(GameMessageType messageType, byte[] data, List<IPEndPoint> players)
        {
            OutgoingMessage com = ServerMessageFormatter.CreateOutgoingMessage(
                (int)messageType,
                data,
                players);

            ExternalOutgoingMessageQueue.Add(com);
        }
Esempio n. 38
0
 public virtual async Task SendGameMessage(GameMessageType message)
 {
 }
Esempio n. 39
0
 public virtual void SendMessageToPlayers(GameMessageType messageType, object dataObject, List<string> players)
 {
     SendMessageToPlayers(messageType, Serializer.GetBytes(dataObject), players);
 }
            private void OnGameMessage(object o, string user,
						    GameMessageType type)
            {
                string msg;
                switch (type)
                  {
                  case GameMessageType.Draw:
                      msg = "<big><b>{0} offers a draw</b>.\nDo you want to agree?</big>";
                      break;
                  case GameMessageType.Abort:
                      msg = "<big><b>{0} wants to abort the game</b>.\nDo you want to agree?</big>";
                      break;
                  default:
                      return;
                  }
                MessageDialog dlg = new MessageDialog (null,
                                       DialogFlags.
                                       Modal,
                                       MessageType.
                                       Question,
                                       ButtonsType.
                                       YesNo,
                                       true,
                                       msg,
                                       user);
                dlg.Modal = false;
                int ret = dlg.Run ();
                if (ret == (int) ResponseType.Yes)
                    client.CommandSender.
                        SendCommand ("accept " +
                                 user);
                else if (ret == (int) ResponseType.No)
                    client.CommandSender.
                        SendCommand ("decline " +
                                 user);
                dlg.Hide ();
                dlg.Dispose ();
            }
Esempio n. 41
0
 public async override Task SendGameMessage(GameMessageType message)
 {
     await Game.ConnectionManager.SendMessage(MessageType.Game, message);
 }
Esempio n. 42
0
 public PlayerLogoutHandler(GatewayNetworkManager2 manager, GameMessageType target)
     : base(manager, target)
 {
 }
Esempio n. 43
0
        public void SendMessage(GameMessageType opcode, object dataObject)
        {
            OutgoingMessage message = MessageFormatter.CreateOutgoingMessage((int)opcode,
                Serializer.GetBytes(dataObject));

            SendMessage(message);
        }
 public TableLeaveNoticeHandler(GatewayNetworkManager2 manager, GameMessageType target)
     : base(manager, target)
 {
 }
Esempio n. 45
0
 public SendMessage(GameMessageType type, string message)
     : base(Build(type, message))
 {
     this.type = type;
     this.message = message;
 }
Esempio n. 46
0
 public VerifyClientHandler(GatewayNetworkManager2 manager, GameMessageType target)
     : base(manager, target)
 {
 }
Esempio n. 47
0
 public static byte[] Build(GameMessageType type, string message)
 {
     return Build(type, message, null);
 }
Esempio n. 48
0
 private ThreadStart GenerateGameMessagePumper(StreamReader input, GameMessageType type, Queue<GameMessage> queue, EventWaitHandle handle)
 {
     return delegate() {
         string line = null;
         while ((line = input.ReadLine()) != null) {
             lock (queue) {
                 queue.Enqueue(new GameMessage() {
                     Type = type,
                     Line = line
                 });
             }
             handle.Set();
         }
     };
 }
Esempio n. 49
0
 /// <summary>
 /// 创建 GenericMessage 对象
 /// </summary>
 /// <param name="type">消息类型</param>
 /// <param name="message">消息内容</param>
 public GenericMessage(GameMessageType type, string message) : base(type, message)
 {
 }
Esempio n. 50
0
 public TableListingHandler(GatewayNetworkManager2 manager, GameMessageType target)
     : base(manager, target)
 {
 }
Esempio n. 51
0
 /// <summary>
 /// 创建 GameMessage 对象
 /// </summary>
 /// <param name="type">游戏消息类型</param>
 /// <param name="message">消息内容</param>
 /// <param name="date">消息创建时间</param>
 protected GameMessage(GameMessageType type, string message, DateTime date)
 {
     Type    = type;
     Message = message;
     Date    = date;
 }
Esempio n. 52
0
 public GameMessage(GameMessageType type, byte charFlags, string charName, string message)
     : base(Build(type, charFlags, charName, message))
 {
     this.unitType = UnitType.NotApplicable;
     this.random = -1;
     this.messageType = type;
     this.playerName = charName;
     this.message = message;
 }