| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library channel; | 5 library channel; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 10 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 * Send the given [request] to the server | 78 * Send the given [request] to the server |
| 79 * and return a future with the associated [Response]. | 79 * and return a future with the associated [Response]. |
| 80 */ | 80 */ |
| 81 Future<Response> sendRequest(Request request); | 81 Future<Response> sendRequest(Request request); |
| 82 } | 82 } |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Instances of the class [JsonStreamDecoder] convert JSON strings to JSON | 85 * Instances of the class [JsonStreamDecoder] convert JSON strings to JSON |
| 86 * maps. | 86 * maps. |
| 87 */ | 87 */ |
| 88 class JsonStreamDecoder extends | 88 class JsonStreamDecoder extends Converter<String, Map> { |
| 89 ChunkedConverter<String, Map, String, Map> { | |
| 90 @override | 89 @override |
| 91 Map convert(String text) => JSON.decode(text); | 90 Map convert(String text) => JSON.decode(text); |
| 92 | 91 |
| 93 @override | 92 @override |
| 94 ChunkedConversionSink<String> startChunkedConversion(Sink<Map> sink) => | 93 ChunkedConversionSink startChunkedConversion(Sink sink) => |
| 95 new ChannelChunkSink<String, Map>(this, sink); | 94 new ChannelChunkSink<String, Map>(this, sink); |
| 96 } | 95 } |
| 97 | 96 |
| 98 /** | 97 /** |
| 99 * Instances of the class [NotificationConverter] convert JSON maps to | 98 * Instances of the class [NotificationConverter] convert JSON maps to |
| 100 * [Notification]s. | 99 * [Notification]s. |
| 101 */ | 100 */ |
| 102 class NotificationConverter extends | 101 class NotificationConverter extends Converter<Map, Notification> { |
| 103 ChunkedConverter<Map, Notification, Map, Notification> { | |
| 104 @override | 102 @override |
| 105 Notification convert(Map json) => new Notification.fromJson(json); | 103 Notification convert(Map json) => new Notification.fromJson(json); |
| 106 | 104 |
| 107 @override | 105 @override |
| 108 ChunkedConversionSink<Map> startChunkedConversion(Sink<Notification> sink) => | 106 ChunkedConversionSink startChunkedConversion(Sink sink) => |
| 109 new ChannelChunkSink<Map, Notification>(this, sink); | 107 new ChannelChunkSink<Map, Notification>(this, sink); |
| 110 } | 108 } |
| 111 | 109 |
| 112 /** | 110 /** |
| 113 * Instances of the class [ResponseConverter] convert JSON maps to [Response]s. | 111 * Instances of the class [ResponseConverter] convert JSON maps to [Response]s. |
| 114 */ | 112 */ |
| 115 class ResponseConverter extends | 113 class ResponseConverter extends Converter<Map, Response> { |
| 116 ChunkedConverter<Map, Response, Map, Response> { | |
| 117 @override | 114 @override |
| 118 Response convert(Map json) => new Response.fromJson(json); | 115 Response convert(Map json) => new Response.fromJson(json); |
| 119 | 116 |
| 120 @override | 117 @override |
| 121 ChunkedConversionSink<Map> startChunkedConversion(Sink<Response> sink) => | 118 ChunkedConversionSink startChunkedConversion(Sink sink) => |
| 122 new ChannelChunkSink<Map, Response>(this, sink); | 119 new ChannelChunkSink<Map, Response>(this, sink); |
| 123 } | 120 } |
| 124 | 121 |
| 125 /** | 122 /** |
| 126 * The abstract class [ServerCommunicationChannel] defines the behavior of | 123 * The abstract class [ServerCommunicationChannel] defines the behavior of |
| 127 * objects that allow an [AnalysisServer] to receive [Request]s and to return | 124 * objects that allow an [AnalysisServer] to receive [Request]s and to return |
| 128 * both [Response]s and [Notification]s. | 125 * both [Response]s and [Notification]s. |
| 129 */ | 126 */ |
| 130 abstract class ServerCommunicationChannel { | 127 abstract class ServerCommunicationChannel { |
| 131 /** | 128 /** |
| (...skipping 14 matching lines...) Expand all Loading... |
| 146 /** | 143 /** |
| 147 * Send the given [notification] to the client. | 144 * Send the given [notification] to the client. |
| 148 */ | 145 */ |
| 149 void sendNotification(Notification notification); | 146 void sendNotification(Notification notification); |
| 150 | 147 |
| 151 /** | 148 /** |
| 152 * Send the given [response] to the client. | 149 * Send the given [response] to the client. |
| 153 */ | 150 */ |
| 154 void sendResponse(Response response); | 151 void sendResponse(Response response); |
| 155 } | 152 } |
| OLD | NEW |