[Modify] Polish it
This commit is contained in:
parent
55aabfbcaf
commit
3ef00d0368
@ -1615,21 +1615,33 @@ namespace WebSocketSharp.Server
|
||||
/// </summary>
|
||||
public void Sweep ()
|
||||
{
|
||||
if (_state != ServerState.Start || _sweeping || Count == 0)
|
||||
if (_sweeping) {
|
||||
_log.Info ("The sweeping is already in progress.");
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_forSweep) {
|
||||
if (_sweeping) {
|
||||
_log.Info ("The sweeping is already in progress.");
|
||||
return;
|
||||
}
|
||||
|
||||
_sweeping = true;
|
||||
}
|
||||
|
||||
foreach (var id in InactiveIDs) {
|
||||
if (_state != ServerState.Start)
|
||||
break;
|
||||
|
||||
lock (_sync) {
|
||||
if (_state != ServerState.Start)
|
||||
break;
|
||||
|
||||
IWebSocketSession session;
|
||||
if (_sessions.TryGetValue (id, out session)) {
|
||||
var state = session.State;
|
||||
if (state == WebSocketState.Open)
|
||||
session.Context.WebSocket.Close (CloseStatusCode.ProtocolError);
|
||||
session.Context.WebSocket.Close (CloseStatusCode.Abnormal);
|
||||
else if (state == WebSocketState.Closing)
|
||||
continue;
|
||||
else
|
||||
@ -1640,7 +1652,6 @@ namespace WebSocketSharp.Server
|
||||
|
||||
_sweeping = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get the session instance with <paramref name="id"/>.
|
||||
|
Loading…
Reference in New Issue
Block a user