From 94afd58b2f97960cac1004f3a8be2681e8e1adac Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Fri, 31 May 2019 08:35:27 -0400 Subject: [PATCH] Require handleMessage to be set before opening scratch-link-socket --- src/util/scratch-link-websocket.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/scratch-link-websocket.js b/src/util/scratch-link-websocket.js index 8eb4c13dc..8c8a2becf 100644 --- a/src/util/scratch-link-websocket.js +++ b/src/util/scratch-link-websocket.js @@ -33,12 +33,12 @@ class ScratchLinkWebSocket { throw new Error(`Unknown ScratchLink socket Type: ${this._type}`); } - if (this._onOpen && this._onClose && this._onError) { + if (this._onOpen && this._onClose && this._onError && this._handleMessage) { this._ws.onopen = this._onOpen; this._ws.onclose = this._onClose; this._ws.onerror = this._onError; } else { - throw new Error('Must set open, close and error handlers before calling open on the socket'); + throw new Error('Must set open, close, message and error handlers before calling open on the socket'); } this._ws.onmessage = this._onMessage.bind(this);