stop method

Future<void> stop()

Stops the WebSocket server and disconnects all clients.

This method closes all active WebSocket connections with connected clients and then shuts down the WebSocket server.

Implementation

Future<void> stop() async {
  for (var client in _clients) {
    await client.close();
  }
  _clients.clear();
  await _server?.close(force: true);
  debugPrint('WebSocket server stopped.');
}