diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4b8bca5c..5af088e5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -226,23 +226,17 @@ namespace WebSocketSharp { return; } - - if (OnClose != null) - { - OnClose(this, new CloseEventArgs(data)); - } - - if (_readyState == WsState.CONNECTING) + else if (_readyState == WsState.CONNECTING) { ReadyState = WsState.CLOSED; + emitOnClose(data); return; } - else - { - ReadyState = WsState.CLOSING; - } - } + ReadyState = WsState.CLOSING; + } + + emitOnClose(data); var frame = new WsFrame(Opcode.CLOSE, data); closeHandshake(frame); #if DEBUG @@ -434,6 +428,14 @@ namespace WebSocketSharp ReadyState = WsState.OPEN; } + private void emitOnClose(PayloadData data) + { + if (OnClose != null) + { + OnClose(this, new CloseEventArgs(data)); + } + } + private void error(string message) { var callerFrame = new StackFrame(1); diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll index 893cd1ec..61b45ff1 100755 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 936a5130..76685d78 100644 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/websocket-sharp/bin/Release/websocket-sharp.dll b/websocket-sharp/bin/Release/websocket-sharp.dll index f34b7c91..79e587c5 100755 Binary files a/websocket-sharp/bin/Release/websocket-sharp.dll and b/websocket-sharp/bin/Release/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll index 5330643e..05099c68 100755 Binary files a/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/websocket-sharp.pidb b/websocket-sharp/websocket-sharp.pidb index 6174b8d3..2f4fa8ed 100644 Binary files a/websocket-sharp/websocket-sharp.pidb and b/websocket-sharp/websocket-sharp.pidb differ