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

Unified Diff: sdk/lib/io/websocket_impl.dart

Issue 300043011: Add WebSockets to Observatory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Deploy Created 6 years, 7 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 | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/websocket_impl.dart
diff --git a/sdk/lib/io/websocket_impl.dart b/sdk/lib/io/websocket_impl.dart
index 475c8f48248a8ff015d53f77e3bfdeff2989c0d7..65e12f4bb5420a646e30ec1e82c8b854fdafb786 100644
--- a/sdk/lib/io/websocket_impl.dart
+++ b/sdk/lib/io/websocket_impl.dart
@@ -741,7 +741,10 @@ class _WebSocketConsumer implements StreamConsumer {
}
-class _WebSocketImpl extends Stream implements WebSocket {
+class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
+ // Use default Map so we keep order.
+ static Map<int, _WebSocketImpl> _webSockets = new Map<int, _WebSocketImpl>();
+
final String protocol;
StreamController _controller;
@@ -892,6 +895,8 @@ class _WebSocketImpl extends Stream implements WebSocket {
onListen: _subscription.resume,
onPause: _subscription.pause,
onResume: _subscription.resume);
+
+ _webSockets[_serviceId] = this;
}
StreamSubscription listen(void onData(message),
@@ -951,6 +956,7 @@ class _WebSocketImpl extends Stream implements WebSocket {
_closeReason = _outCloseReason;
_subscription.cancel();
_controller.close();
+ _webSockets.remove(_serviceId);
});
}
return _sink.close();
@@ -964,6 +970,34 @@ class _WebSocketImpl extends Stream implements WebSocket {
}
_writeClosed = true;
_consumer.closeSocket();
+ _webSockets.remove(_serviceId);
+ }
+
+ String get _serviceTypePath => 'io/websockets';
+ String get _serviceTypeName => 'WebSocket';
+
+ Map _toJSON(bool ref) {
+ var name = '${_socket.address.host}:${_socket.port}';
+ var r = {
+ 'id': _servicePath,
+ 'type': _serviceType(ref),
+ 'name': name,
+ 'user_name': name,
+ };
+ if (ref) {
+ return r;
+ }
+ try {
+ r['socket'] = _socket._toJSON(true);
+ } catch (_) {
+ r['socket'] = {
+ 'id': _servicePath,
+ 'type': '@Socket',
+ 'name': 'UserSocket',
+ 'user_name': 'UserSocket',
+ };
+ }
+ return r;
}
static bool _isReservedStatusCode(int code) {
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698