Modified the WebSocketServer class, fix for 'No Status Code' for the stop
This commit is contained in:
parent
5c0ccc09a5
commit
7b050e07e2
@ -834,20 +834,15 @@ namespace WebSocketSharp.Server
|
|||||||
/// and <see cref="string"/>.
|
/// and <see cref="string"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code">
|
/// <param name="code">
|
||||||
/// A <see cref="ushort"/> that represents the status code indicating the reason for stop.
|
/// A <see cref="ushort"/> that represents the status code indicating the reason for the stop.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="reason">
|
/// <param name="reason">
|
||||||
/// A <see cref="string"/> that represents the reason for stop.
|
/// A <see cref="string"/> that represents the reason for the stop.
|
||||||
/// </param>
|
/// </param>
|
||||||
public void Stop (ushort code, string reason)
|
public void Stop (ushort code, string reason)
|
||||||
{
|
{
|
||||||
CloseEventArgs e = null;
|
|
||||||
lock (_sync) {
|
lock (_sync) {
|
||||||
var msg =
|
var msg = _state.CheckIfStart () ?? code.CheckIfValidCloseParameters (reason);
|
||||||
_state.CheckIfStart () ??
|
|
||||||
code.CheckIfValidCloseStatusCode () ??
|
|
||||||
(e = new CloseEventArgs (code, reason)).RawData.CheckIfValidControlData ("reason");
|
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return;
|
return;
|
||||||
@ -857,9 +852,13 @@ namespace WebSocketSharp.Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopReceiving (5000);
|
stopReceiving (5000);
|
||||||
|
if (code.IsNoStatusCode ()) {
|
||||||
|
_services.Stop (new CloseEventArgs (), true, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
var send = !code.IsReserved ();
|
var send = !code.IsReserved ();
|
||||||
_services.Stop (e, send, send);
|
_services.Stop (new CloseEventArgs (code, reason), send, send);
|
||||||
|
}
|
||||||
|
|
||||||
_state = ServerState.Stop;
|
_state = ServerState.Stop;
|
||||||
}
|
}
|
||||||
@ -870,19 +869,15 @@ namespace WebSocketSharp.Server
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code">
|
/// <param name="code">
|
||||||
/// One of the <see cref="CloseStatusCode"/> enum values, represents the status code
|
/// One of the <see cref="CloseStatusCode"/> enum values, represents the status code
|
||||||
/// indicating the reason for stop.
|
/// indicating the reason for the stop.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="reason">
|
/// <param name="reason">
|
||||||
/// A <see cref="string"/> that represents the reason for stop.
|
/// A <see cref="string"/> that represents the reason for the stop.
|
||||||
/// </param>
|
/// </param>
|
||||||
public void Stop (CloseStatusCode code, string reason)
|
public void Stop (CloseStatusCode code, string reason)
|
||||||
{
|
{
|
||||||
CloseEventArgs e = null;
|
|
||||||
lock (_sync) {
|
lock (_sync) {
|
||||||
var msg =
|
var msg = _state.CheckIfStart () ?? code.CheckIfValidCloseParameters (reason);
|
||||||
_state.CheckIfStart () ??
|
|
||||||
(e = new CloseEventArgs (code, reason)).RawData.CheckIfValidControlData ("reason");
|
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return;
|
return;
|
||||||
@ -892,9 +887,13 @@ namespace WebSocketSharp.Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopReceiving (5000);
|
stopReceiving (5000);
|
||||||
|
if (code.IsNoStatusCode ()) {
|
||||||
|
_services.Stop (new CloseEventArgs (), true, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
var send = !code.IsReserved ();
|
var send = !code.IsReserved ();
|
||||||
_services.Stop (e, send, send);
|
_services.Stop (new CloseEventArgs (code, reason), send, send);
|
||||||
|
}
|
||||||
|
|
||||||
_state = ServerState.Stop;
|
_state = ServerState.Stop;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user