Пример #1
0
        public ServerSideClientFactory(Client.Factory clientFactory, IPlayerList playerList)
        {
            _playerList = playerList;
            _clientFactory = clientFactory;

            _playerList.Players.Clear();
        }
Пример #2
0
        public void RemovesDisconnectingClientWithClientFactory()
        {
            Client client = new Client(null) { ID = 200 };
            clientStateTracker.NetworkClients.Add(client);
            stubNetworkSession.Raise(me => me.ClientDisconnected += null, this, new ClientStatusChangeEventArgs(200, false));

            clientFactory.AssertWasCalled(x => x.DeleteClient(client));
            Assert.AreEqual(0, clientStateTracker.NetworkClients.Count);
        }
 public void SetUp()
 {
     client = new Client(MockRepository.GenerateStub<IPlayer>()) { ID = 10 };
     localClient = new Client(MockRepository.GenerateStub<IPlayer>()) { ID = 99 };
     clientStateTracker = MockRepository.GenerateStub<IClientStateTracker>();
     clientStateTracker.Stub(me => me.FindNetworkClient(10)).Return(client);
     clientStateTracker.Stub(me => me.LocalClient).Return(localClient);
     clientStateTracker.Stub(me => me.NetworkClients).Return(new List<Client>() { client });
     networkPlayerController = new NetworkPlayerProcessor(clientStateTracker);
 }
Пример #4
0
        void SendPlayerToAllClients(Client client)
        {
            IPlayerState state = new PlayerState(client.Player);
            this.OutgoingMessageQueue.AddToQueue(new Item() { ClientID = client.ID, Type = ItemType.Player, Data = state });

            if (client.Player.PlayerSettings.IsDirty)
            {
                this.OutgoingMessageQueue.AddToReliableQueue(new Item() { ClientID = client.ID, Type = ItemType.PlayerSettings, Data = client.Player.PlayerSettings.GetDiff() });
                client.Player.PlayerSettings.Clean();
            }
        }
Пример #5
0
 public void SetUp()
 {
     stubClientStateTracker = MockRepository.GenerateStub<IClientStateTracker>();
     List<Client> clientList = new List<Client>();
     stubClientStateTracker.Stub(x => x.NetworkClients).Return(clientList);
     client = new Client(MockRepository.GenerateStub<IPlayer>());
     client.Player.Stub(me => me.PlayerSettings).Return(MockRepository.GenerateStub<IPlayerSettings>());
     client.Player.Stub(me => me.Weapons).Return(MockRepository.GenerateStub<IWeapons>());
     client.Player.Weapons.Stub(me => me.Shots).Return(new Shots());
     stubClientStateTracker.NetworkClients.Add(client);
     chatLog = new Log<ChatMessage>();
     stubSnapCounter = MockRepository.GenerateStub<ISnapCounter>();
     stubSnapCounter.CurrentSnap = 3;
     stubOutgoingMessageQueue = MockRepository.GenerateStub<IOutgoingMessageQueue>();
     serverChatLogView = new GameStateSender(chatLog, stubClientStateTracker, stubSnapCounter, stubOutgoingMessageQueue);
 }
Пример #6
0
 public void SetUp()
 {
     stubIncomingMessageQueue = MockRepository.GenerateStub<IIncomingMessageQueue>();
     chatLogQueueMessageHelper = new QueuedMessageHelper<Item, ItemType>();
     playerQueueMessageHelper = new QueuedMessageHelper<Item, ItemType>();
     playerSettingsQueueMessageHelper = new QueuedMessageHelper<Item, ItemType>();
     stubIncomingMessageQueue.Stub(x => x.ReadItem(Arg<ItemType>.Is.Equal(ItemType.ChatLog))).Do(chatLogQueueMessageHelper.GetNextQueuedMessage);
     stubIncomingMessageQueue.Stub(x => x.HasAvailable(ItemType.ChatLog)).Do(chatLogQueueMessageHelper.HasMessageAvailable);
     stubIncomingMessageQueue.Stub(x => x.ReadItem(Arg<ItemType>.Is.Equal(ItemType.PlayerInput))).Do(playerQueueMessageHelper.GetNextQueuedMessage);
     stubIncomingMessageQueue.Stub(x => x.HasAvailable(ItemType.PlayerInput)).Do(playerQueueMessageHelper.HasMessageAvailable);
     stubIncomingMessageQueue.Stub(x => x.ReadItem(Arg<ItemType>.Is.Equal(ItemType.PlayerSettings))).Do(playerSettingsQueueMessageHelper.GetNextQueuedMessage);
     stubIncomingMessageQueue.Stub(x => x.HasAvailable(ItemType.PlayerSettings)).Do(playerSettingsQueueMessageHelper.HasMessageAvailable);
     stubClientStateTracker = MockRepository.GenerateStub<IClientStateTracker>();
     stubNetworkPlayerProcessor = MockRepository.GenerateStub<INetworkPlayerProcessor>();
     serverLog = new Log<ChatMessage>();
     client = new Client(MockRepository.GenerateStub<IPlayer>());
     client.Player.Stub(me => me.PlayerSettings).Return(MockRepository.GenerateStub<IPlayerSettings>());
     clientInputProcessor = new ClientInputProcessor(stubNetworkPlayerProcessor, serverLog, stubClientStateTracker, stubIncomingMessageQueue);
 }
Пример #7
0
 public ClientSideClientFactory(Client.Factory clientFactory, IPlayerList playerList, LocalClient localClient)
     : base(clientFactory, playerList)
 {
     _localClient = localClient;
 }
Пример #8
0
 public virtual void DeleteClient(Client client)
 {
     _playerList.Players.Remove(client.Player);
 }