small fixes

This commit is contained in:
Steffen 2020-05-09 21:56:51 +02:00
parent 791c4b322f
commit 2ceee0421b
No known key found for this signature in database
GPG Key ID: 764D74E98267DFC6
2 changed files with 8 additions and 5 deletions

View File

@ -45,7 +45,7 @@
</li> </li>
<li class="headline" v-if="grimoire.sessionId"> <li class="headline" v-if="grimoire.sessionId">
<font-awesome-icon icon="broadcast-tower" /> <font-awesome-icon icon="broadcast-tower" />
{{ grimoire.isSpectator ? "Spectating" : "Hosting" }} {{ grimoire.isSpectator ? "Playing" : "Hosting" }}
</li> </li>
<li @click="leaveSession" v-if="grimoire.sessionId"> <li @click="leaveSession" v-if="grimoire.sessionId">
<em>{{ grimoire.sessionId }}</em> <em>{{ grimoire.sessionId }}</em>
@ -116,9 +116,7 @@ export default {
hostSession() { hostSession() {
const sessionId = prompt( const sessionId = prompt(
"Enter a code for your session", "Enter a code for your session",
Math.random() Math.round(Math.random() * 10000)
.toString(36)
.substring(2, 7)
); );
if (sessionId) { if (sessionId) {
this.$store.commit("setSpectator", false); this.$store.commit("setSpectator", false);

View File

@ -54,7 +54,12 @@ class LiveSession {
* @private * @private
*/ */
_handleMessage({ data }) { _handleMessage({ data }) {
const [command, params] = JSON.parse(data); let command, params;
try {
[command, params] = JSON.parse(data);
} catch (err) {
console.log("unsupported socket message", data);
}
switch (command) { switch (command) {
case "req": case "req":
if (params === "gs") { if (params === "gs") {