stop method

Future<void> stop()

Stops the web server if running.

Implementation

Future<void> stop() async {
  _monitorTimer?.cancel();
  _monitorTimer = null;

  for (final client in _wsClients) {
    try {
      await client.close();
    } catch (e) {
      // Silent close - errors not critical during shutdown
    }
  }
  _wsClients.clear();

  if (_server != null) {
    await _server!.close();
    _server = null;
    _isRunning = false;
  }
}