Pepguy commited on
Commit
89397d0
·
verified ·
1 Parent(s): 033822e

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +4 -0
app.js CHANGED
@@ -32,6 +32,7 @@ app.get('/', (req, res) => {
32
  ws.send(JSON.stringify({ action: 'join', roomId }));
33
  currentRoom = roomId;
34
  log('Joined room: ' + roomId);
 
35
  };
36
  ws.onmessage = ({ data }) => {
37
  const msg = JSON.parse(data);
@@ -60,6 +61,7 @@ wss.on('connection', ws => {
60
 
61
  ws.on('message', raw => {
62
  let msg;
 
63
  try { msg = JSON.parse(raw); } catch (e) { return; }
64
 
65
  if (msg.action === 'join' && msg.roomId) {
@@ -85,12 +87,14 @@ wss.on('connection', ws => {
85
  }
86
  }
87
  }
 
88
  });
89
 
90
  ws.on('close', () => {
91
  if (currentRoom && rooms.has(currentRoom)) {
92
  rooms.get(currentRoom).delete(ws);
93
  }
 
94
  });
95
  });
96
 
 
32
  ws.send(JSON.stringify({ action: 'join', roomId }));
33
  currentRoom = roomId;
34
  log('Joined room: ' + roomId);
35
+ alert('Joined room: ' + roomId);
36
  };
37
  ws.onmessage = ({ data }) => {
38
  const msg = JSON.parse(data);
 
61
 
62
  ws.on('message', raw => {
63
  let msg;
64
+ console.log("message enter")
65
  try { msg = JSON.parse(raw); } catch (e) { return; }
66
 
67
  if (msg.action === 'join' && msg.roomId) {
 
87
  }
88
  }
89
  }
90
+ console.log("message down")
91
  });
92
 
93
  ws.on('close', () => {
94
  if (currentRoom && rooms.has(currentRoom)) {
95
  rooms.get(currentRoom).delete(ws);
96
  }
97
+ console.log("room close")
98
  });
99
  });
100