public void AddClient(LocalClientInterface client) { client.connection = new Connection(nextConnectionId); nextConnectionId++; clients.Add(client); }
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); }
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); }