| 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 Converter<String, Map> { | 88 class JsonStreamDecoder extends |
| 89 ChunkedConverter<String, Map, String, Map> { |
| 89 @override | 90 @override |
| 90 Map convert(String text) => JSON.decode(text); | 91 Map convert(String text) => JSON.decode(text); |
| 91 | 92 |
| 92 @override | 93 @override |
| 93 ChunkedConversionSink startChunkedConversion(Sink sink) => | 94 ChunkedConversionSink<String> startChunkedConversion(Sink<Map> sink) => |
| 94 new ChannelChunkSink<String, Map>(this, sink); | 95 new ChannelChunkSink<String, Map>(this, sink); |
| 95 } | 96 } |
| 96 | 97 |
| 97 /** | 98 /** |
| 98 * Instances of the class [NotificationConverter] convert JSON maps to | 99 * Instances of the class [NotificationConverter] convert JSON maps to |
| 99 * [Notification]s. | 100 * [Notification]s. |
| 100 */ | 101 */ |
| 101 class NotificationConverter extends Converter<Map, Notification> { | 102 class NotificationConverter extends |
| 103 ChunkedConverter<Map, Notification, Map, Notification> { |
| 102 @override | 104 @override |
| 103 Notification convert(Map json) => new Notification.fromJson(json); | 105 Notification convert(Map json) => new Notification.fromJson(json); |
| 104 | 106 |
| 105 @override | 107 @override |
| 106 ChunkedConversionSink startChunkedConversion(Sink sink) => | 108 ChunkedConversionSink<Map> startChunkedConversion(Sink<Notification> sink) => |
| 107 new ChannelChunkSink<Map, Notification>(this, sink); | 109 new ChannelChunkSink<Map, Notification>(this, sink); |
| 108 } | 110 } |
| 109 | 111 |
| 110 /** | 112 /** |
| 111 * Instances of the class [ResponseConverter] convert JSON maps to [Response]s. | 113 * Instances of the class [ResponseConverter] convert JSON maps to [Response]s. |
| 112 */ | 114 */ |
| 113 class ResponseConverter extends Converter<Map, Response> { | 115 class ResponseConverter extends |
| 116 ChunkedConverter<Map, Response, Map, Response> { |
| 114 @override | 117 @override |
| 115 Response convert(Map json) => new Response.fromJson(json); | 118 Response convert(Map json) => new Response.fromJson(json); |
| 116 | 119 |
| 117 @override | 120 @override |
| 118 ChunkedConversionSink startChunkedConversion(Sink sink) => | 121 ChunkedConversionSink<Map> startChunkedConversion(Sink<Response> sink) => |
| 119 new ChannelChunkSink<Map, Response>(this, sink); | 122 new ChannelChunkSink<Map, Response>(this, sink); |
| 120 } | 123 } |
| 121 | 124 |
| 122 /** | 125 /** |
| 123 * The abstract class [ServerCommunicationChannel] defines the behavior of | 126 * The abstract class [ServerCommunicationChannel] defines the behavior of |
| 124 * objects that allow an [AnalysisServer] to receive [Request]s and to return | 127 * objects that allow an [AnalysisServer] to receive [Request]s and to return |
| 125 * both [Response]s and [Notification]s. | 128 * both [Response]s and [Notification]s. |
| 126 */ | 129 */ |
| 127 abstract class ServerCommunicationChannel { | 130 abstract class ServerCommunicationChannel { |
| 128 /** | 131 /** |
| (...skipping 14 matching lines...) Expand all Loading... |
| 143 /** | 146 /** |
| 144 * Send the given [notification] to the client. | 147 * Send the given [notification] to the client. |
| 145 */ | 148 */ |
| 146 void sendNotification(Notification notification); | 149 void sendNotification(Notification notification); |
| 147 | 150 |
| 148 /** | 151 /** |
| 149 * Send the given [response] to the client. | 152 * Send the given [response] to the client. |
| 150 */ | 153 */ |
| 151 void sendResponse(Response response); | 154 void sendResponse(Response response); |
| 152 } | 155 } |
| OLD | NEW |