From 5e5986f5f5b2882526af70f90206c35d67071951 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 19 Feb 2017 08:09:38 +0900 Subject: [PATCH] [Clinet] Fix bug --- src/web/app/common/scripts/messaging-stream.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/web/app/common/scripts/messaging-stream.js b/src/web/app/common/scripts/messaging-stream.js index e6fc6f8bd0..17634c0707 100644 --- a/src/web/app/common/scripts/messaging-stream.js +++ b/src/web/app/common/scripts/messaging-stream.js @@ -3,6 +3,12 @@ const riot = require('riot'); class Connection { constructor(me, otherparty) { + // BIND ----------------------------------- + this.onOpen = this.onOpen.bind(this); + this.onMessage = this.onMessage.bind(this); + this.close = this.close.bind(this); + // ---------------------------------------- + this.event = riot.observable(); this.me = me; @@ -20,8 +26,8 @@ class Connection { onMessage(message) { try { - const message = JSON.parse(message.data); - if (message.type) this.event.trigger(message.type, message.body); + const msg = JSON.parse(message.data); + if (msg.type) this.event.trigger(msg.type, msg.body); } catch(e) { // noop }