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

Unified Diff: runtime/bin/vmservice/vmservice.dart

Issue 112223002: WebSocket client for VM service (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: runtime/bin/vmservice/vmservice.dart
diff --git a/runtime/bin/vmservice/vmservice.dart b/runtime/bin/vmservice/vmservice.dart
index 309399fd227548d12d8968b6af9b6e844a0e6b9e..f24a59ed0e85b5485a35960242dedfc1ff6eedc9 100644
--- a/runtime/bin/vmservice/vmservice.dart
+++ b/runtime/bin/vmservice/vmservice.dart
@@ -9,16 +9,21 @@ import 'dart:convert';
import 'dart:isolate';
import 'dart:typed_data';
+part 'client.dart';
part 'constants.dart';
part 'resources.dart';
part 'running_isolate.dart';
part 'running_isolates.dart';
-part 'service_request.dart';
-part 'service_request_router.dart';
+part 'message.dart';
+part 'message_router.dart';
-class VMService {
+class VMService extends MessageRouter {
static VMService _instance;
+ /// Collection of currently connected clients.
+ final Set<Client> clients = new Set<Client>();
+ /// Collection of currently running isolates.
RunningIsolates runningIsolates = new RunningIsolates();
+ /// Isolate startup and shutdown messages are sent on this port.
final RawReceivePort receivePort;
void controlMessageHandler(int code, int port_id, SendPort sp, String name) {
@@ -32,6 +37,14 @@ class VMService {
}
}
+ void _addClient(Client client) {
+ clients.add(client);
+ }
+
+ void _removeClient(Client client) {
+ clients.remove(client);
+ }
+
void messageHandler(message) {
assert(message is List);
assert(message.length == 4);
@@ -50,6 +63,28 @@ class VMService {
}
return _instance;
}
+
+ void _clientCollection(Message message) {
+ var members = [];
+ var result = {};
+ clients.forEach((client) {
+ members.add(client.toJson());
+ });
+ result['type'] = 'ClientList';
+ result['members'] = members;
+ message.setResponse(JSON.encode(result));
+ }
+
+ Future route(Message message) {
+ if (message.completed) {
+ return message.future;
+ }
+ if ((message.path.length == 1) && (message.path[0] == 'clients')) {
+ _clientCollection(message);
+ return message.future;
+ }
+ return runningIsolates.route(message);
+ }
}
void sendServiceMessage(SendPort sp, ReceivePort rp, Object m)

Powered by Google App Engine
This is Rietveld 408576698