runWebSocket method
Connects to the inspector server. Returns true if the closed connection was successful. Returns false if the connection failed.
Implementation
Future<bool> runWebSocket(String host) async {
try {
final wsUrl = Uri(scheme: 'ws', host: host, port: port);
var channel = WebSocketChannel.connect(wsUrl);
// https://github.com/dart-lang/web_socket_channel/issues/249
await channel.ready;
_controller = WebSocketController(
ref: ref,
sink: channel.sink,
stream: channel.stream,
actions: actions,
theme: theme,
errorParser: errorParser,
);
// drop events scheduled before the connection was established
_unsentEvents.clear();
_eventsScheduler.reset();
await _controller?.handleMessages();
return true;
} catch (e) {
return false;
} finally {
_controller = null;
}
}