Exemple #1
0
        public static T GetDecodedCommand <T>(T c) where T : AbstractCommand
        {
            string          ce = c.Encode();
            AbstractCommand dc = AbstractCommand.DeserializeCommand(ce);

            Assert.AreEqual(c.GetType(), dc.GetType(), "Command and Decoded Command should be the same");
            return((T)dc);
        }
        protected override void OnDataReceived(string data)
        {
            if (!string.IsNullOrEmpty(data))
            {
                var command = AbstractCommand.DeserializeCommand(data);
                Logger.LogCommandReceived(command, this, data);
                switch (command.CommandType)
                {
                case TaluvaCommandEnum.General:
                    m_BluffinServer.LobbyCommands.Add(new CommandEntry()
                    {
                        Client = this, Command = command
                    });
                    lock (m_GamePlayers)
                    {
                        foreach (RemotePlayer p in m_GamePlayers.Values)
                        {
                            m_BluffinServer.GameCommands.Add(new GameCommandEntry()
                            {
                                Client = this, Command = command, Player = p
                            });
                        }
                    }
                    break;

                case TaluvaCommandEnum.Lobby:
                    m_BluffinServer.LobbyCommands.Add(new CommandEntry()
                    {
                        Client = this, Command = command
                    });
                    break;

                case TaluvaCommandEnum.Game:
                    var gc = (AbstractGameCommand)command;
                    lock (m_GamePlayers)
                    {
                        if (m_GamePlayers.ContainsKey(gc.TableId))
                        {
                            m_BluffinServer.GameCommands.Add(new GameCommandEntry()
                            {
                                Client = this, Command = command, Player = m_GamePlayers[gc.TableId]
                            });
                        }
                    }
                    break;
                }
            }
        }
 protected override void OnDataReceived(string data)
 {
     ReceivedCommands.Add(AbstractCommand.DeserializeCommand(data));
 }