[Modify] Polish it
This commit is contained in:
parent
a22bdb9efb
commit
16e5111996
@ -1473,11 +1473,20 @@ namespace WebSocketSharp
|
||||
_receivePong = new AutoResetEvent (false);
|
||||
|
||||
Action receive = null;
|
||||
receive = () => WebSocketFrame.ReadFrameAsync (
|
||||
receive = () =>
|
||||
WebSocketFrame.ReadFrameAsync (
|
||||
_stream,
|
||||
false,
|
||||
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 ();
|
||||
|
||||
if ((frame.IsControl && !(frame.IsPing && _emitOnPing)) || !frame.IsFinal)
|
||||
@ -1493,10 +1502,6 @@ namespace WebSocketSharp
|
||||
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."));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user