Skip to content

Commit 927cca8

Browse files
committed
Hack together way of making ghost pointer reappear in correct location
1 parent f3d9c1a commit 927cca8

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/server/_real_time_logic_test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
});
110110
});
111111

112-
it("redisplays ghost pointer when client has activity after timeout", function() {
112+
it("redisplays ghost pointer when client receives draw message after timeout", function() {
113113
const clientId = "my client ID";
114114
realTimeServer.connectNullClient(clientId);
115115

@@ -120,18 +120,17 @@
120120
serverMessages.push(message);
121121
});
122122

123-
// can't use pointer message because that's what we're looking for
124-
const clientMessage = new ClientDrawMessage(10, 20, 30, 40);
125-
realTimeServer.simulateClientMessage(clientId, clientMessage);
123+
const drawMessage = new ClientDrawMessage(10, 20, 30, 40);
124+
realTimeServer.simulateClientMessage(clientId, drawMessage);
126125

127126
assert.deepEqual(serverMessages, [
128127
{
129-
message: new ServerPointerMessage(clientId, 42, 42),
128+
message: new ServerPointerMessage(clientId, 30, 40), // should appear in correct location
130129
type: RealTimeServer.SEND_TYPE.ALL_CLIENTS_BUT_ONE,
131130
clientId,
132131
},
133132
{
134-
message: clientMessage.toServerMessage(clientId),
133+
message: drawMessage.toServerMessage(clientId),
135134
type: RealTimeServer.SEND_TYPE.ALL_CLIENTS_BUT_ONE,
136135
clientId,
137136
}

src/server/real_time_logic.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
const ServerRemovePointerMessage = require("../shared/server_remove_pointer_message.js");
66
const ServerPointerMessage = require("../shared/server_pointer_message.js");
7+
const ClientDrawMessage = require("../shared/client_draw_message.js");
78
const MessageRepository = require("./message_repository.js");
89
const Clock = require("./clock.js");
910
const RealTimeServer = require("./real_time_server.js");
@@ -66,10 +67,13 @@
6667
resetClientTimeout(clientId);
6768
}
6869

69-
function updateClient({ clientId }) {
70+
function updateClient({ clientId, message }) {
7071
if (!isTrackingClient(clientId)) {
7172
startTrackingClient(clientId);
72-
broadcastAndStoreMessage(self, clientId, new ServerPointerMessage(clientId, 42, 42));
73+
if (message.name() === ClientDrawMessage.MESSAGE_NAME) {
74+
const data = message._data;
75+
broadcastAndStoreMessage(self, clientId, new ServerPointerMessage(clientId, data.toX, data.toY));
76+
}
7377
}
7478
else {
7579
resetClientTimeout(clientId);

todo.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,10 @@ Engineering Tasks:
5757

5858
To Do on current task:
5959
* Make the pointer show up in the right spot
60+
* DrawMessage
61+
- fix internal variable hack
62+
- ClearScreenMessage
63+
- PointerMessage
64+
- RemovePointerMessage
6065
- What's the best way to handle our ordering issues (currently we work around it by just calling trackClientTimeout() first)
6166
- Factor out code to track server messages

0 commit comments

Comments
 (0)