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

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

Issue 1338753004: Force disconnect all service clients when VM is shutting down (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « runtime/bin/vmservice/server.dart ('k') | runtime/vm/service/vmservice.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 final Set<String> streams = new Set<String>(); 11 final Set<String> streams = new Set<String>();
12 12
13 Client(this.service, { bool sendEvents: true }) 13 Client(this.service, { bool sendEvents: true })
14 : this.sendEvents = sendEvents { 14 : this.sendEvents = sendEvents {
15 service._addClient(this); 15 service._addClient(this);
16 } 16 }
17 17
18 // Disconnects the client.
19 disconnect();
20
18 /// When implementing, call [close] when the network connection closes. 21 /// When implementing, call [close] when the network connection closes.
19 void close() { 22 void close() {
20 service._removeClient(this); 23 service._removeClient(this);
21 } 24 }
22 25
23 /// Call to process a message. Response will be posted with 'seq'. 26 /// Call to process a message. Response will be posted with 'seq'.
24 void onMessage(var seq, Message message) { 27 void onMessage(var seq, Message message) {
25 try { 28 try {
26 // Send message to service. 29 // Send message to service.
27 service.route(message).then((response) { 30 service.route(message).then((response) {
28 // Call post when the response arrives. 31 // Call post when the response arrives.
29 post(response); 32 post(response);
30 }); 33 });
31 } catch (e, st) { 34 } catch (e, st) {
32 message.setErrorResponse( 35 message.setErrorResponse(
33 kInternalError, 'Unexpected exception:$e\n$st'); 36 kInternalError, 'Unexpected exception:$e\n$st');
34 post(message.response); 37 post(message.response);
35 } 38 }
36 } 39 }
37 40
38 // Sends a result to the client. Implemented in subclasses. 41 // Sends a result to the client. Implemented in subclasses.
39 void post(dynamic result); 42 void post(dynamic result);
40 43
41 dynamic toJson() { 44 dynamic toJson() {
42 return { 45 return {
43 }; 46 };
44 } 47 }
45 } 48 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/server.dart ('k') | runtime/vm/service/vmservice.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698