Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(754)

Side by Side Diff: runtime/vm/service/client.dart

Issue 1093043004: Do not JSON encode the 'result' of a service rpc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: edits Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of vmservice; 5 part of vmservice;
6 6
7 // A service client. 7 // A service client.
8 abstract class Client { 8 abstract class Client {
9 final VMService service; 9 final VMService service;
10 final bool sendEvents; 10 final bool sendEvents;
11 11
12 Client(this.service, { bool sendEvents: true }) 12 Client(this.service, { bool sendEvents: true })
13 : this.sendEvents = sendEvents { 13 : this.sendEvents = sendEvents {
14 service._addClient(this); 14 service._addClient(this);
15 } 15 }
16 16
17 /// When implementing, call [close] when the network connection closes. 17 /// When implementing, call [close] when the network connection closes.
18 void close() { 18 void close() {
19 service._removeClient(this); 19 service._removeClient(this);
20 } 20 }
21 21
22 /// Call to process a message. Response will be posted with 'seq'. 22 /// Call to process a message. Response will be posted with 'seq'.
23 void onMessage(var seq, Message message) { 23 void onMessage(var seq, Message message) {
24 try { 24 try {
25 // Send message to service. 25 // Send message to service.
26 service.route(message).then((response) { 26 service.route(message).then((response) {
27 // Call post when the response arrives. 27 // Call post when the response arrives.
28 post(seq, response); 28 post(response);
29 }); 29 });
30 } catch (e, st) { 30 } catch (e, st) {
31 message.setErrorResponse('Internal error: $e'); 31 message.setErrorResponse('Internal error: $e');
32 post(seq, message.response); 32 post(message.response);
33 } 33 }
34 } 34 }
35 35
36 // Sends a result to the client. Implemented in subclasses. 36 // Sends a result to the client. Implemented in subclasses.
37 void post(var seq, dynamic result); 37 void post(dynamic result);
38 38
39 dynamic toJson() { 39 dynamic toJson() {
40 return { 40 return {
41 }; 41 };
42 } 42 }
43 } 43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698