Index: runtime/observatory/lib/src/app/application.dart |
diff --git a/runtime/observatory/lib/src/app/application.dart b/runtime/observatory/lib/src/app/application.dart |
index d87d6fb6339416b0ed32c2fe8d92ee40876a3f16..fbe49a8cdbe4dfc919c63ee9c6c95fe126bb9f65 100644 |
--- a/runtime/observatory/lib/src/app/application.dart |
+++ b/runtime/observatory/lib/src/app/application.dart |
@@ -25,8 +25,22 @@ class ObservatoryApplication extends Observable { |
} |
if (vm != null) { |
Logger.root.info('Registering new VM callbacks'); |
- vm.onConnect.then(_vmConnected); |
- vm.onDisconnect.then(_vmDisconnected); |
+ |
+ vm.onConnect.then((_) { |
+ if (vm is WebSocketVM) { |
+ targets.add(vm.target); |
+ } |
+ _removeDisconnectEvents(); |
+ }); |
+ |
+ vm.onDisconnect.then((String reason) { |
+ if (this.vm != vm) { |
+ // This disconnect event occured *after* a new VM was installed. |
+ return; |
+ } |
+ notifications.add(new ServiceEvent.connectionClosed(reason)); |
+ }); |
+ |
vm.errors.stream.listen(_onError); |
vm.events.stream.listen(_onEvent); |
vm.exceptions.stream.listen(_onException); |
@@ -204,23 +218,7 @@ class ObservatoryApplication extends Observable { |
void _removeDisconnectEvents() { |
notifications.removeWhere((oldEvent) { |
- return (oldEvent.eventType == ServiceEvent.kVMDisconnected); |
+ return (oldEvent.eventType == ServiceEvent.kConnectionClosed); |
}); |
} |
- |
- _vmConnected(VM vm) { |
- if (vm is WebSocketVM) { |
- targets.add(vm.target); |
- } |
- _removeDisconnectEvents(); |
- } |
- |
- _vmDisconnected(VM vm) { |
- if (this.vm != vm) { |
- // This disconnect event occured *after* a new VM was installed. |
- return; |
- } |
- this.vm = null; |
- notifications.add(new ServiceEvent.vmDisconencted()); |
- } |
} |