From 2ceee0421b63c2d5d50b1e77183371b0a45f7ee7 Mon Sep 17 00:00:00 2001 From: Steffen Date: Sat, 9 May 2020 21:56:51 +0200 Subject: [PATCH] small fixes --- src/components/Menu.vue | 6 ++---- src/store/session.js | 7 ++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/Menu.vue b/src/components/Menu.vue index 5fada4c..be7633b 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -45,7 +45,7 @@
  • - {{ grimoire.isSpectator ? "Spectating" : "Hosting" }} + {{ grimoire.isSpectator ? "Playing" : "Hosting" }}
  • {{ grimoire.sessionId }} @@ -116,9 +116,7 @@ export default { hostSession() { const sessionId = prompt( "Enter a code for your session", - Math.random() - .toString(36) - .substring(2, 7) + Math.round(Math.random() * 10000) ); if (sessionId) { this.$store.commit("setSpectator", false); diff --git a/src/store/session.js b/src/store/session.js index d0021e2..652632b 100644 --- a/src/store/session.js +++ b/src/store/session.js @@ -54,7 +54,12 @@ class LiveSession { * @private */ _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) { case "req": if (params === "gs") {