| 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/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
| 11 import 'package:analyzer/src/util/utilities_timing.dart'; |
| 11 | 12 |
| 12 /** | 13 /** |
| 13 * The abstract class [ClientCommunicationChannel] defines the behavior of | 14 * The abstract class [ClientCommunicationChannel] defines the behavior of |
| 14 * objects that allow a client to send [Request]s to an [AnalysisServer] and to | 15 * objects that allow a client to send [Request]s to an [AnalysisServer] and to |
| 15 * receive both [Response]s and [Notification]s. | 16 * receive both [Response]s and [Notification]s. |
| 16 */ | 17 */ |
| 17 abstract class ClientCommunicationChannel { | 18 abstract class ClientCommunicationChannel { |
| 18 /** | 19 /** |
| 19 * The stream of notifications from the server. | 20 * The stream of notifications from the server. |
| 20 */ | 21 */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 38 Future close(); | 39 Future close(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 /** | 42 /** |
| 42 * The abstract class [ServerCommunicationChannel] defines the behavior of | 43 * The abstract class [ServerCommunicationChannel] defines the behavior of |
| 43 * objects that allow an [AnalysisServer] to receive [Request]s and to return | 44 * objects that allow an [AnalysisServer] to receive [Request]s and to return |
| 44 * both [Response]s and [Notification]s. | 45 * both [Response]s and [Notification]s. |
| 45 */ | 46 */ |
| 46 abstract class ServerCommunicationChannel { | 47 abstract class ServerCommunicationChannel { |
| 47 /** | 48 /** |
| 49 * A stopwatch used to accumulate the amount of time spent converting |
| 50 * incomming requests from Json to objects. |
| 51 */ |
| 52 static final CountedStopwatch FromJson = new CountedStopwatch(); |
| 53 |
| 54 /** |
| 55 * A stopwatch used to accumulate the amount of time spent converting outgoing |
| 56 * responses and notifications from objects to Json. |
| 57 */ |
| 58 static final CountedStopwatch ToJson = new CountedStopwatch(); |
| 59 |
| 60 /** |
| 48 * Listen to the channel for requests. If a request is received, invoke the | 61 * Listen to the channel for requests. If a request is received, invoke the |
| 49 * [onRequest] function. If an error is encountered while trying to read from | 62 * [onRequest] function. If an error is encountered while trying to read from |
| 50 * the socket, invoke the [onError] function. If the socket is closed by the | 63 * the socket, invoke the [onError] function. If the socket is closed by the |
| 51 * client, invoke the [onDone] function. | 64 * client, invoke the [onDone] function. |
| 52 * Only one listener is allowed per channel. | 65 * Only one listener is allowed per channel. |
| 53 */ | 66 */ |
| 54 void listen(void onRequest(Request request), {Function onError, void onDone()}
); | 67 void listen(void onRequest(Request request), {Function onError, void onDone()}
); |
| 55 | 68 |
| 56 /** | 69 /** |
| 57 * Send the given [notification] to the client. | 70 * Send the given [notification] to the client. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 155 } |
| 143 } | 156 } |
| 144 } | 157 } |
| 145 | 158 |
| 146 @override | 159 @override |
| 147 void close() { | 160 void close() { |
| 148 closed = true; | 161 closed = true; |
| 149 sink.close(); | 162 sink.close(); |
| 150 } | 163 } |
| 151 } | 164 } |
| OLD | NEW |