JoinRoom now ONLY sends the roomId.
This commit is contained in:
parent
7e00d61f94
commit
cdfa9acf01
4 changed files with 57 additions and 116 deletions
|
@ -17,39 +17,19 @@ describe("World", () => {
|
|||
|
||||
let world = new World(connect, disconnect, 160, 160, () => {}, () => {});
|
||||
|
||||
world.join({ id: "foo" }, new MessageUserPosition({
|
||||
userId: "foofoo",
|
||||
roomId: 1,
|
||||
position: new Point(100, 100)
|
||||
}));
|
||||
world.join({ id: "foo" }, new Point(100, 100));
|
||||
|
||||
world.join({ id: "bar" }, new MessageUserPosition({
|
||||
userId: "barbar",
|
||||
roomId: 1,
|
||||
position: new Point(500, 100)
|
||||
}));
|
||||
world.join({ id: "bar" }, new Point(500, 100));
|
||||
|
||||
world.updatePosition({ id: "bar" }, new MessageUserPosition({
|
||||
userId: "barbar",
|
||||
roomId: 1,
|
||||
position: new Point(261, 100)
|
||||
}));
|
||||
world.updatePosition({ id: "bar" }, new Point(261, 100));
|
||||
|
||||
expect(connectCalledNumber).toBe(0);
|
||||
|
||||
world.updatePosition({ id: "bar" }, new MessageUserPosition({
|
||||
userId: "barbar",
|
||||
roomId: 1,
|
||||
position: new Point(101, 100)
|
||||
}));
|
||||
world.updatePosition({ id: "bar" }, new Point(101, 100));
|
||||
|
||||
expect(connectCalledNumber).toBe(2);
|
||||
|
||||
world.updatePosition({ id: "bar" }, new MessageUserPosition({
|
||||
userId: "barbar",
|
||||
roomId: 1,
|
||||
position: new Point(102, 100)
|
||||
}));
|
||||
world.updatePosition({ id: "bar" }, new Point(102, 100));
|
||||
expect(connectCalledNumber).toBe(2);
|
||||
});
|
||||
|
||||
|
@ -64,35 +44,19 @@ describe("World", () => {
|
|||
|
||||
let world = new World(connect, disconnect, 160, 160, () => {}, () => {});
|
||||
|
||||
world.join({ id: "foo" }, new MessageUserPosition({
|
||||
userId: "foofoo",
|
||||
roomId: 1,
|
||||
position: new Point(100, 100)
|
||||
}));
|
||||
world.join({ id: "foo" }, new Point(100, 100));
|
||||
|
||||
world.join({ id: "bar" }, new MessageUserPosition({
|
||||
userId: "barbar",
|
||||
roomId: 1,
|
||||
position: new Point(200, 100)
|
||||
}));
|
||||
world.join({ id: "bar" }, new Point(200, 100));
|
||||
|
||||
expect(connectCalled).toBe(true);
|
||||
connectCalled = false;
|
||||
|
||||
// baz joins at the outer limit of the group
|
||||
world.join({ id: "baz" }, new MessageUserPosition({
|
||||
userId: "bazbaz",
|
||||
roomId: 1,
|
||||
position: new Point(311, 100)
|
||||
}));
|
||||
world.join({ id: "baz" }, new Point(311, 100));
|
||||
|
||||
expect(connectCalled).toBe(false);
|
||||
|
||||
world.updatePosition({ id: "baz" }, new MessageUserPosition({
|
||||
userId: "bazbaz",
|
||||
roomId: 1,
|
||||
position: new Point(309, 100)
|
||||
}));
|
||||
world.updatePosition({ id: "baz" }, new Point(309, 100));
|
||||
|
||||
expect(connectCalled).toBe(true);
|
||||
});
|
||||
|
@ -109,34 +73,18 @@ describe("World", () => {
|
|||
|
||||
let world = new World(connect, disconnect, 160, 160, () => {}, () => {});
|
||||
|
||||
world.join({ id: "foo" }, new MessageUserPosition({
|
||||
userId: "foofoo",
|
||||
roomId: 1,
|
||||
position: new Point(100, 100)
|
||||
}));
|
||||
world.join({ id: "foo" }, new Point(100, 100));
|
||||
|
||||
world.join({ id: "bar" }, new MessageUserPosition({
|
||||
userId: "barbar",
|
||||
roomId: 1,
|
||||
position: new Point(259, 100)
|
||||
}));
|
||||
world.join({ id: "bar" }, new Point(259, 100));
|
||||
|
||||
expect(connectCalled).toBe(true);
|
||||
expect(disconnectCallNumber).toBe(0);
|
||||
|
||||
world.updatePosition({ id: "bar" }, new MessageUserPosition({
|
||||
userId: "barbar",
|
||||
roomId: 1,
|
||||
position: new Point(100+160+160+1, 100)
|
||||
}));
|
||||
world.updatePosition({ id: "bar" }, new Point(100+160+160+1, 100));
|
||||
|
||||
expect(disconnectCallNumber).toBe(2);
|
||||
|
||||
world.updatePosition({ id: "bar" }, new MessageUserPosition({
|
||||
userId: "barbar",
|
||||
roomId: 1,
|
||||
position: new Point(262, 100)
|
||||
}));
|
||||
world.updatePosition({ id: "bar" }, new Point(262, 100));
|
||||
expect(disconnectCallNumber).toBe(2);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue