mirror of https://github.com/bra1n/townsquare.git
improved session handling
This commit is contained in:
parent
32c837f441
commit
6dd797aa6d
|
@ -19,7 +19,9 @@ wss.on("connection", function connection(ws, req) {
|
||||||
.pop()
|
.pop()
|
||||||
.toLocaleLowerCase();
|
.toLocaleLowerCase();
|
||||||
ws.on("message", function incoming(data) {
|
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) {
|
wss.clients.forEach(function each(client) {
|
||||||
if (
|
if (
|
||||||
client !== ws &&
|
client !== ws &&
|
||||||
|
|
|
@ -140,14 +140,14 @@ export default {
|
||||||
},
|
},
|
||||||
hostSession() {
|
hostSession() {
|
||||||
const sessionId = prompt(
|
const sessionId = prompt(
|
||||||
"Enter a channel number for your session",
|
"Enter a channel number / name for your session",
|
||||||
Math.round(Math.random() * 10000)
|
Math.round(Math.random() * 10000)
|
||||||
);
|
);
|
||||||
if (sessionId) {
|
if (sessionId) {
|
||||||
this.$store.commit("setSpectator", false);
|
this.$store.commit("setSpectator", false);
|
||||||
this.$store.commit(
|
this.$store.commit(
|
||||||
"setSessionId",
|
"setSessionId",
|
||||||
sessionId.replace(/[^0-9]/g, "").substr(0, 5)
|
sessionId.replace(/[^0-9a-z]/g, "").substr(0, 5)
|
||||||
);
|
);
|
||||||
this.copySessionUrl();
|
this.copySessionUrl();
|
||||||
}
|
}
|
||||||
|
@ -166,13 +166,13 @@ export default {
|
||||||
},
|
},
|
||||||
joinSession() {
|
joinSession() {
|
||||||
const sessionId = prompt(
|
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) {
|
if (sessionId) {
|
||||||
this.$store.commit("setSpectator", true);
|
this.$store.commit("setSpectator", true);
|
||||||
this.$store.commit(
|
this.$store.commit(
|
||||||
"setSessionId",
|
"setSessionId",
|
||||||
sessionId.replace(/[^0-9]/g, "").substr(0, 5)
|
sessionId.replace(/[^0-9a-z]/g, "").substr(0, 5)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue