diff options
-rw-r--r-- | web_socket.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/web_socket.js b/web_socket.js index 9951c71..abd5093 100644 --- a/web_socket.js +++ b/web_socket.js @@ -158,14 +158,14 @@ if ("readyState" in event) { this.readyState = event.readyState; } - + try { - if (event.type == "open" && this.onopen) { - this.onopen(); - } else if (event.type == "close" && this.onclose) { - this.onclose(); - } else if (event.type == "error" && this.onerror) { - this.onerror(event); + if (event.type == "open") { + this.onopen && this.onopen(); + } else if (event.type == "close") { + this.onclose && this.onclose(); + } else if (event.type == "error") { + this.onerror && this.onerror(event); } else if (event.type == "message") { if (this.onmessage) { var data = decodeURIComponent(event.message); |