vmServiceOpened method

Future<void> vmServiceOpened(
  1. VmService service
)
inherited

Implementation

Future<void> vmServiceOpened(VmService service) async {
  Log.i(_kTag, 'vmServiceOpened');

  this.service = service;

  isolateManager.vmServiceOpened(service);

  void handleServiceEvent(Event e) {
    Log.i(_kTag, 'handleServiceEvent kind=${e.kind} service=${e.service} method=${e.method}');

    if (e.kind == EventKind.kServiceRegistered) {
      _registeredMethodsForService.putIfAbsent(e.service!, () => []).add(e.method!);
    }
    if (e.kind == EventKind.kServiceUnregistered) {
      _registeredMethodsForService.remove(e.service!); // ignore: unnecessary_null_checks
    }
  }

  service.onEvent(EventStreams.kService).listen(handleServiceEvent);
  unawaited(service.streamListen(EventStreams.kService));

  unawaited(service.onDone.then((Object? _) {
    Log.i(_kTag, 'VMService.onDone called');
    this.service = null;
  }));

  vm = await service.getVM();

  final isolates = <IsolateRef>[
    ...vm?.isolates ?? [],
  ];

  await isolateManager.init(isolates);
  if (service != this.service) {
    // A different service has been opened.
    return;
  }
}