[Modify] Add it
This commit is contained in:
		@@ -775,6 +775,61 @@ namespace WebSocketSharp.Server
 | 
			
		||||
      _receiveThread.Start ();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void stop (ushort code, string reason)
 | 
			
		||||
    {
 | 
			
		||||
      if (_state == ServerState.Ready) {
 | 
			
		||||
        _log.Info ("The server is not started.");
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (_state == ServerState.ShuttingDown) {
 | 
			
		||||
        _log.Info ("The server is shutting down.");
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (_state == ServerState.Stop) {
 | 
			
		||||
        _log.Info ("The server has already stopped.");
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      lock (_sync) {
 | 
			
		||||
        if (_state == ServerState.ShuttingDown) {
 | 
			
		||||
          _log.Info ("The server is shutting down.");
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (_state == ServerState.Stop) {
 | 
			
		||||
          _log.Info ("The server has already stopped.");
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        _state = ServerState.ShuttingDown;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      try {
 | 
			
		||||
        var threw = false;
 | 
			
		||||
        try {
 | 
			
		||||
          _services.Stop (code, reason);
 | 
			
		||||
        }
 | 
			
		||||
        catch {
 | 
			
		||||
          threw = true;
 | 
			
		||||
          throw;
 | 
			
		||||
        }
 | 
			
		||||
        finally {
 | 
			
		||||
          try {
 | 
			
		||||
            stopReceiving (5000);
 | 
			
		||||
          }
 | 
			
		||||
          catch {
 | 
			
		||||
            if (!threw)
 | 
			
		||||
              throw;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      finally {
 | 
			
		||||
        _state = ServerState.Stop;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void stopReceiving (int millisecondsTimeout)
 | 
			
		||||
    {
 | 
			
		||||
      _listener.Close ();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user