diff --git a/stream.js b/stream.js index 5b4b59f..7f7764c 100644 --- a/stream.js +++ b/stream.js @@ -83,7 +83,7 @@ function WebSocketStream(target, protocols, options) { } // was already open when passed in - if (socket.readyState === WS.OPEN) { + if (socket.readyState === socket.OPEN) { stream = proxy } else { stream = duplexify.obj() @@ -103,7 +103,7 @@ function WebSocketStream(target, protocols, options) { function socketWriteNode(chunk, enc, next) { // avoid errors, this never happens unless // destroy() is called - if (socket.readyState !== WS.OPEN) { + if (socket.readyState !== socket.OPEN) { next() return } diff --git a/ws-fallback.js b/ws-fallback.js index 8173b48..aca0c2b 100644 --- a/ws-fallback.js +++ b/ws-fallback.js @@ -2,11 +2,11 @@ var ws = null if (typeof WebSocket !== 'undefined') { - ws = WebSocket + ws = WebSocket } else if (typeof MozWebSocket !== 'undefined') { - ws = MozWebSocket -} else { - ws = window.WebSocket || window.MozWebSocket + ws = MozWebSocket +} else if (typeof window !== 'undefined') { + ws = window.WebSocket || window.MozWebSocket } module.exports = ws