public void TestEvilUpdate() { Packet packet = new Packet(0); FakeEndPoint firstEndPoint = new FakeEndPoint("tester", 0); transport.ClientEnqueue(packet, firstEndPoint.Address, firstEndPoint.Port); server.SingleStep(); Cube cube = server.Spawn <Cube>(); FakeEndPoint secondEndPoint = new FakeEndPoint("foobar", 1); transport.ClientEnqueue(packet, secondEndPoint.Address, secondEndPoint.Port); server.SingleStep(); uint firstClientId = server.GetClient(firstEndPoint).Id; Assert.That(firstClientId, Is.Not.EqualTo(0)); uint secondClientId = server.GetClient(secondEndPoint).Id; Assert.That(secondClientId, Is.Not.EqualTo(0)); Packet move = new Packet(3, secondClientId, 1.0f, 1.0f, 2.0f); transport.ClientEnqueue(move, "tester", 0); Assert.That(() => server.SingleStep(), Throws.InstanceOf <DifferentAvatarOwningUse>()); // get the id from the welcome packets // try to move the id from the other player }
public override bool Equals(object obj) { FakeEndPoint other = obj as FakeEndPoint; if (other == null) { return(false); } return((this.address == other.address) && (this.port == other.port)); }
public void TestClientIsAvatarOwner() { Packet packet = new Packet(0); FakeEndPoint endPoint = new FakeEndPoint("tester", 0); transport.ClientEnqueue(packet, endPoint.Address, endPoint.Port); server.SingleStep(); GameClient client = server.ClientsTable[endPoint]; Avatar avatar = server.GetAvatar(client); Assert.That(client.Id, Is.EqualTo(avatar.Id)); }
public void TestAckPacketWorks() { FakeEndPoint endPoint = new FakeEndPoint("tester", 0); GameClient client = new GameClient(server, endPoint); Packet packet = new Packet(1, 1, 1, 0, 0, 0); packet.NeedsAck = true; client.Enqueue(packet); client.Process(); Assert.That(client.AckTable, Is.Not.Empty); }
public void TestPacketSendAfter() { FakeEndPoint endPoint = new FakeEndPoint("tester", 0); GameClient client = new GameClient(server, endPoint); Packet packet = new Packet(1, 1, 1, 0, 0, 0); packet.SendAfter = server.Now + 1f; client.Enqueue(packet); client.Process(); Assert.That(transport.ClientQueueCounter, Is.EqualTo(0)); }
public void TestAvatarPositionVectorIsZeroOnRegistration() { Packet packet = new Packet(0); FakeEndPoint endPoint = new FakeEndPoint("tester", 0); transport.ClientEnqueue(packet, endPoint.Address, endPoint.Port); server.SingleStep(); GameClient client = server.ClientsTable[endPoint]; Avatar avatar = server.GetAvatar(client); Assert.That(avatar.X, Is.EqualTo(0)); Assert.That(avatar.Y, Is.EqualTo(0)); Assert.That(avatar.Z, Is.EqualTo(0)); }
public void Bind(string address, int port) { boundAddress = new FakeEndPoint(address, port); }