[Modify] Polish it
This commit is contained in:
parent
a22bdb9efb
commit
16e5111996
@ -1473,11 +1473,20 @@ namespace WebSocketSharp
|
|||||||
_receivePong = new AutoResetEvent (false);
|
_receivePong = new AutoResetEvent (false);
|
||||||
|
|
||||||
Action receive = null;
|
Action receive = null;
|
||||||
receive = () => WebSocketFrame.ReadFrameAsync (
|
receive = () =>
|
||||||
_stream,
|
WebSocketFrame.ReadFrameAsync (
|
||||||
false,
|
_stream,
|
||||||
frame => {
|
false,
|
||||||
if (processReceivedFrame (frame) && _readyState != WebSocketState.Closed) {
|
frame => {
|
||||||
|
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,12 +1502,8 @@ 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) {
|
ex => processException (ex, "An exception has occurred while receiving a message."));
|
||||||
_exitReceiving.Set ();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ex => processException (ex, "An exception has occurred while receiving a message."));
|
|
||||||
|
|
||||||
receive ();
|
receive ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user