Modified closing
This commit is contained in:
@@ -462,9 +462,9 @@ namespace WebSocketSharp.Server
|
||||
return;
|
||||
}
|
||||
|
||||
_serviceHosts.Stop (data);
|
||||
_listener.Close ();
|
||||
_receiveRequestThread.Join (5 * 1000);
|
||||
_serviceHosts.Stop (code, reason);
|
||||
_listening = false;
|
||||
}
|
||||
|
||||
@@ -579,9 +579,9 @@ namespace WebSocketSharp.Server
|
||||
if (!_listening)
|
||||
return;
|
||||
|
||||
_serviceHosts.Stop ();
|
||||
_listener.Close ();
|
||||
_receiveRequestThread.Join (5 * 1000);
|
||||
_serviceHosts.Stop ();
|
||||
_listening = false;
|
||||
}
|
||||
|
||||
|
@@ -201,14 +201,11 @@ namespace WebSocketSharp.Server
|
||||
void Stop ();
|
||||
|
||||
/// <summary>
|
||||
/// Stops the WebSocket service host with the specified <see cref="ushort"/> and <see cref="string"/>.
|
||||
/// Stops the WebSocket service host with the specified array of <see cref="byte"/>.
|
||||
/// </summary>
|
||||
/// <param name="code">
|
||||
/// A <see cref="ushort"/> that contains a status code indicating the reason for stop.
|
||||
/// <param name="data">
|
||||
/// An array of <see cref="byte"/> that contains the reason for stop.
|
||||
/// </param>
|
||||
/// <param name="reason">
|
||||
/// A <see cref="string"/> that contains the reason for stop.
|
||||
/// </param>
|
||||
void Stop (ushort code, string reason);
|
||||
void Stop (byte [] data);
|
||||
}
|
||||
}
|
||||
|
@@ -207,7 +207,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
base.Stop ();
|
||||
_serviceHosts.Stop (code, reason);
|
||||
_serviceHosts.Stop (data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@@ -211,6 +211,11 @@ namespace WebSocketSharp.Server
|
||||
_websocket.SendAsync (data, completed);
|
||||
}
|
||||
|
||||
internal void Stop (byte [] data)
|
||||
{
|
||||
_websocket.Close (data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Methods
|
||||
|
@@ -280,7 +280,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
base.Stop ();
|
||||
_sessions.Stop (code, reason);
|
||||
_sessions.Stop (data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -765,19 +765,15 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops receiving the WebSocket connection requests with the specified <see cref="ushort"/> and
|
||||
/// <see cref="string"/>.
|
||||
/// Stops the WebSocket service host with the specified array of <see cref="byte"/>.
|
||||
/// </summary>
|
||||
/// <param name="code">
|
||||
/// A <see cref="ushort"/> that contains a status code indicating the reason for stop.
|
||||
/// <param name="data">
|
||||
/// An array of <see cref="byte"/> that contains the reason for stop.
|
||||
/// </param>
|
||||
/// <param name="reason">
|
||||
/// A <see cref="string"/> that contains the reason for stop.
|
||||
/// </param>
|
||||
void IWebSocketServiceHost.Stop (ushort code, string reason)
|
||||
void IWebSocketServiceHost.Stop (byte [] data)
|
||||
{
|
||||
base.Stop ();
|
||||
_sessions.Stop (code, reason);
|
||||
_sessions.Stop (data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@@ -193,7 +193,7 @@ namespace WebSocketSharp.Server
|
||||
_serviceHosts.Remove (servicePath);
|
||||
}
|
||||
|
||||
host.Stop ((ushort) CloseStatusCode.AWAY, String.Empty);
|
||||
host.Stop (((ushort) CloseStatusCode.AWAY).ToByteArray (ByteOrder.BIG));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -208,12 +208,12 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
}
|
||||
|
||||
internal void Stop (ushort code, string reason)
|
||||
internal void Stop (byte [] data)
|
||||
{
|
||||
lock (_sync)
|
||||
{
|
||||
foreach (var host in _serviceHosts.Values)
|
||||
host.Stop (code, reason);
|
||||
host.Stop (data);
|
||||
|
||||
_serviceHosts.Clear ();
|
||||
}
|
||||
|
@@ -508,7 +508,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
}
|
||||
|
||||
internal void Stop (ushort code, string reason)
|
||||
internal void Stop (byte [] data)
|
||||
{
|
||||
stopSweepTimer ();
|
||||
lock (_sync)
|
||||
@@ -518,7 +518,7 @@ namespace WebSocketSharp.Server
|
||||
|
||||
_stopped = true;
|
||||
foreach (var service in copy ().Values)
|
||||
service.Stop (code, reason);
|
||||
service.Stop (data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,7 +588,7 @@ namespace WebSocketSharp.Server
|
||||
{
|
||||
var state = service.WebSocket.ReadyState;
|
||||
if (state == WebSocketState.OPEN)
|
||||
service.Stop (CloseStatusCode.ABNORMAL, String.Empty);
|
||||
service.Stop (((ushort) CloseStatusCode.ABNORMAL).ToByteArray (ByteOrder.BIG));
|
||||
else if (state == WebSocketState.CLOSING)
|
||||
continue;
|
||||
else
|
||||
|
Reference in New Issue
Block a user