Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 part of vmservice; | |
| 6 | |
| 7 // A service client. | |
| 8 abstract class Client { | |
| 9 /// Port that lives as long as the network client. | |
| 10 final RawReceivePort receivePort = new RawReceivePort(); | |
| 11 final VMService service; | |
| 12 | |
| 13 Client(this.service) { | |
| 14 receivePort.handler = (response) { | |
| 15 post(null, response); | |
| 16 }; | |
| 17 service._addClient(this); | |
| 18 } | |
| 19 | |
| 20 /// When implementing, call [close] when the network connection closes. | |
| 21 void close() { | |
| 22 receivePort.close(); | |
| 23 service._removeClient(this); | |
| 24 } | |
| 25 | |
| 26 /// Call to process a message. Response will be sent with 'seq'. | |
| 27 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.
| |
| 28 // Call post when the response arrives. | |
| 29 message.future.then((response) { | |
| 30 post(seq, response); | |
| 31 }); | |
| 32 // Send message to service. | |
| 33 service.route(message); | |
| 34 } | |
| 35 | |
| 36 /// When implementing, responsible for sending [response] to the client. | |
| 37 void post(var seq, String response); | |
| 38 | |
| 39 Map toJson() { | |
| 40 return { | |
| 41 }; | |
|
turnidge
2013/12/11 17:56:07
Should we leave this abstract too?
Cutch
2013/12/12 22:37:42
Done.
| |
| 42 } | |
| 43 } | |
| OLD | NEW |