From 385214f5205d7dc366f7ed70ce6c1ec1943fe70e Mon Sep 17 00:00:00 2001 From: "Glitch (hello-express)" Date: Thu, 9 Apr 2020 11:28:30 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=BA=F0=9F=8C=98=20Checkpoint=20./views?= =?UTF-8?q?/room.handlebars:530995/1530=20./server.js:530995/548=20./publi?= =?UTF-8?q?c/style.css:530995/195?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/style.css | 8 ++++++++ server.js | 19 ++++++++++++------- views/room.handlebars | 36 ++++++++++++++++++++---------------- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/public/style.css b/public/style.css index ab2ab2b..db92fa4 100644 --- a/public/style.css +++ b/public/style.css @@ -54,3 +54,11 @@ footer { padding-top: 1.5em; border-top: 1px solid lightgrey; } + +#buzzer { + width: 90vw; + height: 90vh; + margin: 0 auto; + border-radius: 100%; + background: red; +} \ No newline at end of file diff --git a/server.js b/server.js index 498fa20..de54f5f 100644 --- a/server.js +++ b/server.js @@ -58,12 +58,17 @@ server.listen(process.env.PORT, () => { const wss = new WebSocket.Server({ server }); wss.on('connection', (ws, req) => { - ws.on('message', (message) => { - message = JSON.stringify(message); - console.log(message) - console.log(message.type) - console.log(message.data) - }); + let participant; + ws.on('message', (message) => { + message = JSON.parse(message); + if (message.type === "join") { + participant = message.data; + ws.send('Joined as ' + participant.participantName); + } + if (message.type === "buzz") { + // TODO: Handle Buzzer + } + }); - ws.send('Connected'); + ws.send('Connected'); }); \ No newline at end of file diff --git a/views/room.handlebars b/views/room.handlebars index 15efa15..b2204ca 100644 --- a/views/room.handlebars +++ b/views/room.handlebars @@ -24,25 +24,29 @@