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()
|
||||
.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 &&
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue