[Modify] Replace it
This commit is contained in:
parent
2018fca931
commit
f8f8189b4b
@ -968,6 +968,20 @@ namespace WebSocketSharp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fatal (string message, Exception exception)
|
||||||
|
{
|
||||||
|
var code = exception is WebSocketException
|
||||||
|
? ((WebSocketException) exception).Code
|
||||||
|
: CloseStatusCode.Abnormal;
|
||||||
|
|
||||||
|
close (
|
||||||
|
new CloseEventArgs (code, message ?? code.GetMessage ()),
|
||||||
|
!code.IsReserved (),
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private void init ()
|
private void init ()
|
||||||
{
|
{
|
||||||
_compression = CompressionMethod.None;
|
_compression = CompressionMethod.None;
|
||||||
@ -1558,28 +1572,33 @@ namespace WebSocketSharp
|
|||||||
_receivePong = new AutoResetEvent (false);
|
_receivePong = new AutoResetEvent (false);
|
||||||
|
|
||||||
Action receive = null;
|
Action receive = null;
|
||||||
receive = () =>
|
receive =
|
||||||
WebSocketFrame.ReadFrameAsync (
|
() =>
|
||||||
_stream,
|
WebSocketFrame.ReadFrameAsync (
|
||||||
false,
|
_stream,
|
||||||
frame => {
|
false,
|
||||||
if (!processReceivedFrame (frame) || _readyState == WebSocketState.Closed) {
|
frame => {
|
||||||
var exit = _exitReceiving;
|
if (!processReceivedFrame (frame) || _readyState == WebSocketState.Closed) {
|
||||||
if (exit != null)
|
var exit = _exitReceiving;
|
||||||
exit.Set ();
|
if (exit != null)
|
||||||
|
exit.Set ();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Receive next asap because the Ping or Close needs a response to it.
|
||||||
|
receive ();
|
||||||
|
|
||||||
|
if (_inMessage || !HasMessage || _readyState != WebSocketState.Open)
|
||||||
|
return;
|
||||||
|
|
||||||
|
message ();
|
||||||
|
},
|
||||||
|
ex => {
|
||||||
|
_logger.Fatal (ex.ToString ());
|
||||||
|
fatal ("An exception has occurred while receiving.", ex);
|
||||||
}
|
}
|
||||||
|
);
|
||||||
// Receive next asap because the Ping or Close needs a response to it.
|
|
||||||
receive ();
|
|
||||||
|
|
||||||
if (_inMessage || !HasMessage || _readyState != WebSocketState.Open)
|
|
||||||
return;
|
|
||||||
|
|
||||||
message ();
|
|
||||||
},
|
|
||||||
ex => processException (ex, "An exception has occurred while receiving a message."));
|
|
||||||
|
|
||||||
receive ();
|
receive ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user