private GameServerStream ProcessRequest(string clientTokenValue, GameServerStream current) { switch (current.MessageType) { case MsgType.Initialisation: return(new GameServerStream() { MessageType = MsgType.Initialisation, MessageState = true, Message = string.Empty }); case MsgType.Invitation: Log.Debug($"Invitation reply received."); goto case MsgType.InGame; case MsgType.InGame: ProcessGameData(current.MessageType, current.MessageState, JsonConvert.DeserializeObject <GameData>(current.Message)); return(null); default: return(new GameServerStream() { MessageType = MsgType.Initialisation, MessageState = false, Message = string.Empty }); } }
public void SendGameData(UserClient player, int playerId, MsgType messageType, bool messageState, GameDataType gameDataType, string gameDataObject = "") { var gameServerStream = new GameServerStream() { MessageType = messageType, MessageState = messageState, Message = JsonConvert.SerializeObject(new GameData() { GameId = GameId, PlayerId = playerId, GameDataType = gameDataType, GameDataObject = gameDataObject }) }; player.responseQueue.Enqueue(gameServerStream); player.Visitors.ForEach(p => { p.responseQueue.Enqueue(gameServerStream); }); if (true) { var gameLogPath = UserById(playerId) == Player1 ? _player1GameLogName : _player2GameLogName; using (StreamWriter outputFile = new StreamWriter(Path.Combine(Environment.CurrentDirectory, gameLogPath), true)) { outputFile.WriteLine(JsonConvert.SerializeObject(gameServerStream)); } } }
private GameServerStream ProcessRequest(GameServerStream current) { switch (current.MessageType) { case MsgType.Initialisation: return(new GameServerStream() { MessageType = MsgType.Initialisation, MessageState = true, Message = string.Empty }); case MsgType.Invitation: case MsgType.InGame: ProcessGameData(current.MessageType, current.MessageState, JsonConvert.DeserializeObject <GameData>(current.Message)); return(null); default: return(new GameServerStream() { MessageType = MsgType.Initialisation, MessageState = false, Message = string.Empty }); } }