예제 #1
0
        public void AddClient(LocalClientInterface client)
        {
            client.connection = new Connection(nextConnectionId);
            nextConnectionId++;

            clients.Add(client);
        }
예제 #2
0
        public void TestClientReactor()
        {
            var client  = new LocalClientInterface();
            var reactor = new ClientReactor(client);

            bool messageHandlerCalled = false;

            reactor.AddHandler(1, (BitReader bs) => {
                messageHandlerCalled = true;
            });

            var message = new BitWriter();

            message.WriteByte((byte)1);
            client.EnqueueMessage(message);

            client.Update();

            Assert.IsTrue(messageHandlerCalled);
        }
예제 #3
0
        public void Send(BitWriter bs, PacketReliability reliablity, Connection connection, int sequenceChannel)
        {
            bs.FlushBits();

            LocalClientInterface targetClient = null;

            foreach (var client in clients)
            {
                if (client.connection == connection)
                {
                    targetClient = client;
                    break;
                }
            }

            if (targetClient == null)
            {
                throw new Exception("Client not found.");
            }

            targetClient.EnqueueMessage(bs);
        }