public static void AssertAllOfType(this JsonMessageLog log, GameMessageType messageType) { foreach (dynamic msg in log.Messages) { Assert.IsTrue(msg.type == messageType.ToString()); } }
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); } }
public Frame(int roomid, object data, MessageType messageType, GameMessageType gameMessageType) { RoomId = roomid; Data = data; MsgType = messageType; GameMsgType = gameMessageType; }
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(); }
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); }
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; } }
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); }
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); } }
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); } }
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() ); }
public SendMessage(GameMessageType type, string message, string recipient) : base(Build(type, message, recipient)) { this.type = type; this.message = message; this.recipient = recipient; }
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); }
// 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); } }
public virtual void SendMessageToPlayers(GameMessageType messageType, byte[] data, List<string> players) { SendMessageToPlayers(messageType, data, ResolvePlayers(players)); }
public void OutputLine(GameMessageType type, string line) { DedicatedLauncher.Singleton.EnqueueUxJob(delegate () { Window.Log(string.Format("[{0}] {1}", type, line)); }); }
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) { }
// 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); } }
public MessagesRoutingKeyBuilder WithMessageType(GameMessageType messageType) => new MessagesRoutingKeyBuilder { SocialNetwork = SocialNetwork, MessageType = messageType };
private bool ProcessGameMessage(string name, GameMessageType type) { if (GameMessageEvent != null) GameMessageEvent (this, name, type); return true; }
public GameMessage(GameMessageType type) : base((int)type) { m_messageType = type; }
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; }
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; }
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; }
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; }
public GameMessage getData(GameMessageType t) { return(data[(int)t]); }
/// <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); }
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; }
/// <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); }
public virtual void SendMessageToPlayers(GameMessageType messageType, byte[] data, List<IPEndPoint> players) { OutgoingMessage com = ServerMessageFormatter.CreateOutgoingMessage( (int)messageType, data, players); ExternalOutgoingMessageQueue.Add(com); }
public virtual async Task SendGameMessage(GameMessageType message) { }
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 (); }
public async override Task SendGameMessage(GameMessageType message) { await Game.ConnectionManager.SendMessage(MessageType.Game, message); }
public PlayerLogoutHandler(GatewayNetworkManager2 manager, GameMessageType target) : base(manager, target) { }
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) { }
public SendMessage(GameMessageType type, string message) : base(Build(type, message)) { this.type = type; this.message = message; }
public VerifyClientHandler(GatewayNetworkManager2 manager, GameMessageType target) : base(manager, target) { }
public static byte[] Build(GameMessageType type, string message) { return Build(type, message, null); }
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(); } }; }
/// <summary> /// 创建 GenericMessage 对象 /// </summary> /// <param name="type">消息类型</param> /// <param name="message">消息内容</param> public GenericMessage(GameMessageType type, string message) : base(type, message) { }
public TableListingHandler(GatewayNetworkManager2 manager, GameMessageType target) : base(manager, target) { }
/// <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; }
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; }