Implementation
@Deprecated('Prefer vmServiceConnectUri')
Future<VmService> vmServiceConnect(String host, int port, {Log? log}) async {
final WebSocket socket = await WebSocket.connect('ws://$host:$port/ws');
final StreamController<dynamic> controller = StreamController();
final Completer streamClosedCompleter = Completer();
socket.listen(
(data) => controller.add(data),
onDone: () => streamClosedCompleter.complete(),
);
return VmService(
controller.stream,
(String message) => socket.add(message),
log: log,
disposeHandler: () => socket.close(),
streamClosed: streamClosedCompleter.future,
);
}