|
|
|
@ -749,20 +749,15 @@ namespace WebSocketSharp.Server
|
|
|
|
/// <see cref="string"/> used to stop the WebSocket services.
|
|
|
|
/// <see cref="string"/> used to stop the WebSocket services.
|
|
|
|
/// </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;
|
|
|
|
@ -771,8 +766,13 @@ namespace WebSocketSharp.Server
|
|
|
|
_state = ServerState.ShuttingDown;
|
|
|
|
_state = ServerState.ShuttingDown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var send = !code.IsReserved ();
|
|
|
|
if (code.IsNoStatusCode ()) {
|
|
|
|
_services.Stop (e, send, send);
|
|
|
|
_services.Stop (new CloseEventArgs (), true, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
var send = !code.IsReserved ();
|
|
|
|
|
|
|
|
_services.Stop (new CloseEventArgs (code, reason), send, send);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stopReceiving (5000);
|
|
|
|
stopReceiving (5000);
|
|
|
|
|
|
|
|
|
|
|
|
@ -785,19 +785,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 reasons 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;
|
|
|
|
@ -806,8 +802,13 @@ namespace WebSocketSharp.Server
|
|
|
|
_state = ServerState.ShuttingDown;
|
|
|
|
_state = ServerState.ShuttingDown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var send = !code.IsReserved ();
|
|
|
|
if (code.IsNoStatusCode ()) {
|
|
|
|
_services.Stop (e, send, send);
|
|
|
|
_services.Stop (new CloseEventArgs (), true, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
var send = !code.IsReserved ();
|
|
|
|
|
|
|
|
_services.Stop (new CloseEventArgs (code, reason), send, send);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stopReceiving (5000);
|
|
|
|
stopReceiving (5000);
|
|
|
|
|
|
|
|
|
|
|
|
|