|
|
|
@ -1615,21 +1615,33 @@ namespace WebSocketSharp.Server
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public void Sweep ()
|
|
|
|
public void Sweep ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_state != ServerState.Start || _sweeping || Count == 0)
|
|
|
|
if (_sweeping) {
|
|
|
|
|
|
|
|
_log.Info ("The sweeping is already in progress.");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lock (_forSweep) {
|
|
|
|
lock (_forSweep) {
|
|
|
|
|
|
|
|
if (_sweeping) {
|
|
|
|
|
|
|
|
_log.Info ("The sweeping is already in progress.");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_sweeping = true;
|
|
|
|
_sweeping = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var id in InactiveIDs) {
|
|
|
|
foreach (var id in InactiveIDs) {
|
|
|
|
if (_state != ServerState.Start)
|
|
|
|
if (_state != ServerState.Start)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
lock (_sync) {
|
|
|
|
lock (_sync) {
|
|
|
|
|
|
|
|
if (_state != ServerState.Start)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
IWebSocketSession session;
|
|
|
|
IWebSocketSession session;
|
|
|
|
if (_sessions.TryGetValue (id, out session)) {
|
|
|
|
if (_sessions.TryGetValue (id, out session)) {
|
|
|
|
var state = session.State;
|
|
|
|
var state = session.State;
|
|
|
|
if (state == WebSocketState.Open)
|
|
|
|
if (state == WebSocketState.Open)
|
|
|
|
session.Context.WebSocket.Close (CloseStatusCode.ProtocolError);
|
|
|
|
session.Context.WebSocket.Close (CloseStatusCode.Abnormal);
|
|
|
|
else if (state == WebSocketState.Closing)
|
|
|
|
else if (state == WebSocketState.Closing)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@ -1640,7 +1652,6 @@ namespace WebSocketSharp.Server
|
|
|
|
|
|
|
|
|
|
|
|
_sweeping = false;
|
|
|
|
_sweeping = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Tries to get the session instance with <paramref name="id"/>.
|
|
|
|
/// Tries to get the session instance with <paramref name="id"/>.
|
|
|
|
|