handleWebSocket method
Implementation
Future<void> handleWebSocket(HttpRequest request) async {
final socket = await WebSocketTransformer.upgrade(request);
// Add the connected client to the list
connectedClients.add(socket);
// Handle incoming messages
socket.listen((dynamic data) {
// Handle incoming messages (if needed)
});
// Handle disconnections
socket.done.then((_) {
connectedClients.remove(socket);
print('Client disconnected');
});
}