diff --git a/src/trans-websocket.coffee b/src/trans-websocket.coffee index 37b8d6b5..fbde4941 100644 --- a/src/trans-websocket.coffee +++ b/src/trans-websocket.coffee @@ -73,7 +73,7 @@ class WebSocketReceiver extends transport.GenericReceiver try message = JSON.parse(payload) catch x - return @didClose(1002, 'Broken framing.') + return @session.close(1002, 'Broken framing.') if payload[0] is '[' for msg in message @session.didMessage(msg) diff --git a/src/transport.coffee b/src/transport.coffee index e9b97ec0..f3e7c7ab 100644 --- a/src/transport.coffee +++ b/src/transport.coffee @@ -237,7 +237,7 @@ class GenericReceiver @setUp(@thingy) setUp: -> - @thingy_end_cb = () => @didAbort(1006, "Connection closed") + @thingy_end_cb = () => @didAbort() @thingy.addListener('close', @thingy_end_cb) @thingy.addListener('end', @thingy_end_cb) @@ -246,18 +246,18 @@ class GenericReceiver @thingy.removeListener('end', @thingy_end_cb) @thingy_end_cb = null - didAbort: (status, reason) -> + didAbort: -> session = @session - @didClose(status, reason) + @didClose() if session session.didTimeout() - didClose: (status, reason) -> + didClose: -> if @thingy @tearDown(@thingy) @thingy = null if @session - @session.unregister(status, reason) + @session.unregister() doSendBulk: (messages) -> q_msgs = for m in messages