Spaces:
Sleeping
Sleeping
Update app.js
Browse files
app.js
CHANGED
|
@@ -26,6 +26,7 @@ app.get('/', (req, res) => {
|
|
| 26 |
let ws, currentRoom = null;
|
| 27 |
|
| 28 |
function joinRoom() {
|
|
|
|
| 29 |
const roomId = document.getElementById('room').value;
|
| 30 |
ws = new WebSocket('ws://' + location.host);
|
| 31 |
ws.onopen = () => {
|
|
@@ -39,6 +40,9 @@ app.get('/', (req, res) => {
|
|
| 39 |
log('[' + msg.roomId + '] ' + msg.message);
|
| 40 |
};
|
| 41 |
ws.onclose = () => log('Disconnected.');
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
function sendMsg() {
|
|
@@ -58,6 +62,7 @@ app.get('/', (req, res) => {
|
|
| 58 |
|
| 59 |
wss.on('connection', ws => {
|
| 60 |
let currentRoom = null;
|
|
|
|
| 61 |
|
| 62 |
ws.on('message', raw => {
|
| 63 |
let msg;
|
|
|
|
| 26 |
let ws, currentRoom = null;
|
| 27 |
|
| 28 |
function joinRoom() {
|
| 29 |
+
try {
|
| 30 |
const roomId = document.getElementById('room').value;
|
| 31 |
ws = new WebSocket('ws://' + location.host);
|
| 32 |
ws.onopen = () => {
|
|
|
|
| 40 |
log('[' + msg.roomId + '] ' + msg.message);
|
| 41 |
};
|
| 42 |
ws.onclose = () => log('Disconnected.');
|
| 43 |
+
} catch (err) {
|
| 44 |
+
alert("err "+err)
|
| 45 |
+
}
|
| 46 |
}
|
| 47 |
|
| 48 |
function sendMsg() {
|
|
|
|
| 62 |
|
| 63 |
wss.on('connection', ws => {
|
| 64 |
let currentRoom = null;
|
| 65 |
+
console.log("fresh connect")
|
| 66 |
|
| 67 |
ws.on('message', raw => {
|
| 68 |
let msg;
|