Fixed close(PayloadData data) method in websocket-sharp/WebSocket.cs

This commit is contained in:
sta 2012-07-31 16:42:34 +09:00
parent 118e0015d5
commit a93dcc09aa
6 changed files with 14 additions and 12 deletions

View File

@ -226,23 +226,17 @@ namespace WebSocketSharp
{ {
return; return;
} }
else if (_readyState == WsState.CONNECTING)
if (OnClose != null)
{
OnClose(this, new CloseEventArgs(data));
}
if (_readyState == WsState.CONNECTING)
{ {
ReadyState = WsState.CLOSED; ReadyState = WsState.CLOSED;
emitOnClose(data);
return; return;
} }
else
{
ReadyState = WsState.CLOSING;
}
}
ReadyState = WsState.CLOSING;
}
emitOnClose(data);
var frame = new WsFrame(Opcode.CLOSE, data); var frame = new WsFrame(Opcode.CLOSE, data);
closeHandshake(frame); closeHandshake(frame);
#if DEBUG #if DEBUG
@ -434,6 +428,14 @@ namespace WebSocketSharp
ReadyState = WsState.OPEN; ReadyState = WsState.OPEN;
} }
private void emitOnClose(PayloadData data)
{
if (OnClose != null)
{
OnClose(this, new CloseEventArgs(data));
}
}
private void error(string message) private void error(string message)
{ {
var callerFrame = new StackFrame(1); var callerFrame = new StackFrame(1);

Binary file not shown.