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

Unified Diff: pkg/analysis_server/lib/src/channel/web_socket_channel.dart

Issue 725143004: Format and sort analyzer and analysis_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | « pkg/analysis_server/lib/src/channel/channel.dart ('k') | pkg/analysis_server/lib/src/collections.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/channel/web_socket_channel.dart
diff --git a/pkg/analysis_server/lib/src/channel/web_socket_channel.dart b/pkg/analysis_server/lib/src/channel/web_socket_channel.dart
index c661bfb90b51ae359c58ff808ef78889210fdfaf..8dfcb5c552ff294ac1871a1ec676217f3e2bee8c 100644
--- a/pkg/analysis_server/lib/src/channel/web_socket_channel.dart
+++ b/pkg/analysis_server/lib/src/channel/web_socket_channel.dart
@@ -8,8 +8,8 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
-import 'package:analysis_server/src/protocol.dart';
import 'package:analysis_server/src/channel/channel.dart';
+import 'package:analysis_server/src/protocol.dart';
/**
@@ -33,19 +33,23 @@ class WebSocketClientChannel implements ClientCommunicationChannel {
* Initialize a new [WebSocket] wrapper for the given [socket].
*/
WebSocketClientChannel(this.socket) {
- Stream jsonStream = socket
- .where((data) => data is String)
- .transform(new JsonStreamDecoder())
- .where((json) => json is Map)
- .asBroadcastStream();
- responseStream = jsonStream
- .where((json) => json[Notification.EVENT] == null)
- .transform(new ResponseConverter())
- .asBroadcastStream();
- notificationStream = jsonStream
- .where((json) => json[Notification.EVENT] != null)
- .transform(new NotificationConverter())
- .asBroadcastStream();
+ Stream jsonStream = socket.where(
+ (data) =>
+ data is String).transform(
+ new JsonStreamDecoder()).where((json) => json is Map).asBroadcastStream();
+ responseStream = jsonStream.where(
+ (json) =>
+ json[Notification.EVENT] ==
+ null).transform(new ResponseConverter()).asBroadcastStream();
+ notificationStream = jsonStream.where(
+ (json) =>
+ json[Notification.EVENT] !=
+ null).transform(new NotificationConverter()).asBroadcastStream();
+ }
+
+ @override
+ Future close() {
+ return socket.close();
}
@override
@@ -54,11 +58,6 @@ class WebSocketClientChannel implements ClientCommunicationChannel {
socket.add(JSON.encode(request.toJson()));
return responseStream.firstWhere((Response response) => response.id == id);
}
-
- @override
- Future close() {
- return socket.close();
- }
}
/**
@@ -78,25 +77,17 @@ class WebSocketServerChannel implements ServerCommunicationChannel {
WebSocketServerChannel(this.socket);
@override
- void listen(void onRequest(Request request), {void onError(), void onDone()}) {
- socket.listen((data) => readRequest(data, onRequest), onError: onError,
- onDone: onDone);
- }
-
- @override
- void sendNotification(Notification notification) {
- ServerCommunicationChannel.ToJson.start();
- String jsonEncoding = JSON.encode(notification.toJson());
- ServerCommunicationChannel.ToJson.stop();
- socket.add(jsonEncoding);
+ void close() {
+ socket.close(WebSocketStatus.NORMAL_CLOSURE);
}
@override
- void sendResponse(Response response) {
- ServerCommunicationChannel.ToJson.start();
- String jsonEncoding = JSON.encode(response.toJson());
- ServerCommunicationChannel.ToJson.stop();
- socket.add(jsonEncoding);
+ void listen(void onRequest(Request request), {void onError(), void
+ onDone()}) {
+ socket.listen(
+ (data) => readRequest(data, onRequest),
+ onError: onError,
+ onDone: onDone);
}
/**
@@ -124,7 +115,18 @@ class WebSocketServerChannel implements ServerCommunicationChannel {
}
@override
- void close() {
- socket.close(WebSocketStatus.NORMAL_CLOSURE);
+ void sendNotification(Notification notification) {
+ ServerCommunicationChannel.ToJson.start();
+ String jsonEncoding = JSON.encode(notification.toJson());
+ ServerCommunicationChannel.ToJson.stop();
+ socket.add(jsonEncoding);
+ }
+
+ @override
+ void sendResponse(Response response) {
+ ServerCommunicationChannel.ToJson.start();
+ String jsonEncoding = JSON.encode(response.toJson());
+ ServerCommunicationChannel.ToJson.stop();
+ socket.add(jsonEncoding);
}
}
« no previous file with comments | « pkg/analysis_server/lib/src/channel/channel.dart ('k') | pkg/analysis_server/lib/src/collections.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698