Skip to content

Commit f92c4c2

Browse files
author
Dennis Trautwein
committed
Let connect() method wait until there is an actual connection
1 parent a79e46e commit f92c4c2

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

lib/src/remote_devtools_middleware.dart

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ class RemoteDevToolsMiddleware extends MiddlewareClass {
5555
this._channel = await this._login();
5656
_setStatus(RemoteDevToolsStatus.starting);
5757
this._relay('START');
58+
59+
await Future (() {
60+
final c = Completer();
61+
this.socket.on(_channel, (String name, dynamic data) {
62+
if (data['type'] == "START") {
63+
_setStatus(RemoteDevToolsStatus.started);
64+
c.complete();
65+
} else {
66+
c.completeError(data);
67+
}
68+
});
69+
return c.future;
70+
});
71+
5872
this.socket.on(_channel, (String name, dynamic data) {
5973
this.handleEventFromRemote(data as Map<String, dynamic>);
6074
});
@@ -95,9 +109,9 @@ class RemoteDevToolsMiddleware extends MiddlewareClass {
95109
case 'DISPATCH':
96110
_handleDispatch(data['action']);
97111
break;
98-
// The START action is a response indicating that remote devtools is up and running
99-
case 'START':
100-
_setStatus(RemoteDevToolsStatus.started);
112+
// The START action is a response indicating that remote devtools is up and running
113+
case 'START':
114+
_setStatus(RemoteDevToolsStatus.started);
101115
break;
102116
case 'ACTION':
103117
_handleRemoteAction(data['action'] as String);

0 commit comments

Comments
 (0)