Skip to content

Commit

Permalink
Reimplement sending events to renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
MacaylaMarvelous81 committed Aug 20, 2024
1 parent 9c301bb commit dc06552
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ wss.on('connection', async (ws) => {
const client = new Client(ws);

await client.enableEncryption();

client.onGameEvent((name, body) => sendAllRenderers(`event:${ name }`, body));

client.subscribeEvent('PlayerDied');
client.subscribeEvent('ItemUsed');
client.subscribeEvent('PlayerMessage');
Expand Down
2 changes: 1 addition & 1 deletion websocket/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class Client {

delete this.#commandRequests[data?.header?.requestId];
} else if (data?.header?.messagePurpose === 'event') {
this.#gameEventHandlers.forEach((handler) => handler(data?.header?.eventName), data?.body);
this.#gameEventHandlers.forEach((handler) => handler(data?.header?.eventName, data?.body));
}
}
}

0 comments on commit dc06552

Please sign in to comment.