improved session handling

This commit is contained in:
Steffen 2020-05-30 22:01:42 +02:00
parent 32c837f441
commit 6dd797aa6d
No known key found for this signature in database
GPG Key ID: 764D74E98267DFC6
2 changed files with 7 additions and 5 deletions

View File

@ -19,7 +19,9 @@ wss.on("connection", function connection(ws, req) {
.pop()
.toLocaleLowerCase();
ws.on("message", function incoming(data) {
console.log(data);
if (!data.match(/^\["ping/i)) {
console.log(ws.channel, wss.clients.size, data);
}
wss.clients.forEach(function each(client) {
if (
client !== ws &&

View File

@ -140,14 +140,14 @@ export default {
},
hostSession() {
const sessionId = prompt(
"Enter a channel number for your session",
"Enter a channel number / name for your session",
Math.round(Math.random() * 10000)
);
if (sessionId) {
this.$store.commit("setSpectator", false);
this.$store.commit(
"setSessionId",
sessionId.replace(/[^0-9]/g, "").substr(0, 5)
sessionId.replace(/[^0-9a-z]/g, "").substr(0, 5)
);
this.copySessionUrl();
}
@ -166,13 +166,13 @@ export default {
},
joinSession() {
const sessionId = prompt(
"Enter the channel number of the session you want to join"
"Enter the channel number / name of the session you want to join"
);
if (sessionId) {
this.$store.commit("setSpectator", true);
this.$store.commit(
"setSessionId",
sessionId.replace(/[^0-9]/g, "").substr(0, 5)
sessionId.replace(/[^0-9a-z]/g, "").substr(0, 5)
);
}
},