Chromium Code Reviews| Index: runtime/bin/vmservice/client.dart |
| diff --git a/runtime/bin/vmservice/client.dart b/runtime/bin/vmservice/client.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..557ef2495339571760430d6bdf350773ce1b3f23 |
| --- /dev/null |
| +++ b/runtime/bin/vmservice/client.dart |
| @@ -0,0 +1,43 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +part of vmservice; |
| + |
| +// A service client. |
| +abstract class Client { |
| + /// Port that lives as long as the network client. |
| + final RawReceivePort receivePort = new RawReceivePort(); |
| + final VMService service; |
| + |
| + Client(this.service) { |
| + receivePort.handler = (response) { |
| + post(null, response); |
| + }; |
| + service._addClient(this); |
| + } |
| + |
| + /// When implementing, call [close] when the network connection closes. |
| + void close() { |
| + receivePort.close(); |
| + service._removeClient(this); |
| + } |
| + |
| + /// Call to process a message. Response will be sent with 'seq'. |
| + void onMessage(var seq, var message) { |
|
turnidge
2013/12/11 17:56:07
Could we type message here? I assume it is Messag
Cutch
2013/12/12 22:37:42
Done.
|
| + // Call post when the response arrives. |
| + message.future.then((response) { |
| + post(seq, response); |
| + }); |
| + // Send message to service. |
| + service.route(message); |
| + } |
| + |
| + /// When implementing, responsible for sending [response] to the client. |
| + void post(var seq, String response); |
| + |
| + Map toJson() { |
| + return { |
| + }; |
|
turnidge
2013/12/11 17:56:07
Should we leave this abstract too?
Cutch
2013/12/12 22:37:42
Done.
|
| + } |
| +} |