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

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

Issue 2980733003: Introduced support for external services registration in the ServiceProtocol (Closed)
Patch Set: Address comments Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/observatory/.packages » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/server.dart
diff --git a/runtime/bin/vmservice/server.dart b/runtime/bin/vmservice/server.dart
index bae52fab5e615a60548d682c006dc77cb0214935..b0f12db16d8b760215faca00778a965465407fa9 100644
--- a/runtime/bin/vmservice/server.dart
+++ b/runtime/bin/vmservice/server.dart
@@ -45,11 +45,22 @@ class WebSocketClient extends Client {
socket.close(NOT_MAP_ERROR_CODE, 'Message must be a JSON map.');
return;
}
- var serial = map['id'];
- if (serial != null && serial is! num && serial is! String) {
- socket.close(ID_ERROR_CODE, '"id" must be a number, string, or null.');
+ try {
+ final rpc = new Message.fromJsonRpc(this, map);
+ switch (rpc.type) {
+ case MessageType.Request:
+ onRequest(rpc);
+ break;
+ case MessageType.Notification:
+ onNotification(rpc);
+ break;
+ case MessageType.Response:
+ onResponse(rpc);
+ break;
+ }
+ } catch (e) {
+ socket.close(ID_ERROR_CODE, e.message);
}
- onMessage(serial, new Message.fromJsonRpc(this, map));
} else {
socket.close(BINARY_MESSAGE_ERROR_CODE, 'Message must be a string.');
}
@@ -71,8 +82,8 @@ class WebSocketClient extends Client {
}
} catch (e, st) {
serverPrint("Ignoring error posting over WebSocket.");
- serverPrint(e);
- serverPrint(st);
+ serverPrint(e.toString());
+ serverPrint(st.toString());
}
}
@@ -311,15 +322,9 @@ class Server {
return;
}
// HTTP based service request.
- try {
- var client = new HttpRequestClient(request, _service);
- var message = new Message.fromUri(client, request.uri);
- client.onMessage(null, message);
- } catch (e) {
- serverPrint('Unexpected error processing HTTP request uri: '
- '${request.uri}\n$e\n');
- rethrow;
- }
+ final client = new HttpRequestClient(request, _service);
+ final message = new Message.fromUri(client, request.uri);
+ client.onRequest(message); // exception free, no need to try catch
}
Future startup() async {
« no previous file with comments | « no previous file | runtime/observatory/.packages » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698