示例#1
0
        public void Queue_CanPull_RemovingPulledObjects()
        {
            IGameUpdate o1 = new GameUpdate {
                IPAddress = "STRING", GameState = "1"
            };
            IGameUpdate o2 = new GameUpdate {
                IPAddress = "STRING", GameState = "2"
            };

            _queue.Push(o1);
            _queue.Push(o2);

            var result = _queue.Pull();

            result.GameState.ShouldBe("1");

            _queue.Size().ShouldBe(1);
        }
示例#2
0
        private Thread CreateProcessorThread()
        {
            Thread processorThread = new Thread(() =>
            {
                while (true)
                {
                    string gameState = _queue.Pull();
                    if (gameState != null)
                    {
                        string[] gameCommands = gameState.Split("_");

                        foreach (var command in gameCommands)
                        {
                            if (command != null)
                            {
                                _commandDecoder.Decode(command); // TODO rename Decode to something more appropiate
                            }
                        }
                    }
                }
            });

            return(processorThread);
        }