|
|
|
@ -1473,11 +1473,20 @@ namespace WebSocketSharp
|
|
|
|
_receivePong = new AutoResetEvent (false);
|
|
|
|
_receivePong = new AutoResetEvent (false);
|
|
|
|
|
|
|
|
|
|
|
|
Action receive = null;
|
|
|
|
Action receive = null;
|
|
|
|
receive = () => WebSocketFrame.ReadFrameAsync (
|
|
|
|
receive = () =>
|
|
|
|
|
|
|
|
WebSocketFrame.ReadFrameAsync (
|
|
|
|
_stream,
|
|
|
|
_stream,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
frame => {
|
|
|
|
frame => {
|
|
|
|
if (processReceivedFrame (frame) && _readyState != WebSocketState.Closed) {
|
|
|
|
if (!processReceivedFrame (frame) || _readyState == WebSocketState.Closed) {
|
|
|
|
|
|
|
|
var exit = _exitReceiving;
|
|
|
|
|
|
|
|
if (exit != null)
|
|
|
|
|
|
|
|
exit.Set ();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Receive next asap because a Ping or Close needs a response to it.
|
|
|
|
receive ();
|
|
|
|
receive ();
|
|
|
|
|
|
|
|
|
|
|
|
if ((frame.IsControl && !(frame.IsPing && _emitOnPing)) || !frame.IsFinal)
|
|
|
|
if ((frame.IsControl && !(frame.IsPing && _emitOnPing)) || !frame.IsFinal)
|
|
|
|
@ -1493,10 +1502,6 @@ namespace WebSocketSharp
|
|
|
|
processException (ex, "An exception has occurred during an OnMessage event.");
|
|
|
|
processException (ex, "An exception has occurred during an OnMessage event.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (_exitReceiving != null) {
|
|
|
|
|
|
|
|
_exitReceiving.Set ();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ex => processException (ex, "An exception has occurred while receiving a message."));
|
|
|
|
ex => processException (ex, "An exception has occurred while receiving a message."));
|
|
|
|
|
|
|
|
|
|
|
|
|