OLD | NEW |
---|---|
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:analyzer_plugin/protocol/protocol.dart'; | 5 import 'package:analyzer_plugin/protocol/protocol.dart'; |
6 | 6 |
7 /** | 7 /** |
8 * The object that allows a [ServerPlugin] to receive [Request]s and to return | 8 * A communication channel that allows a [ServerPlugin] to receive [Request]s |
9 * both [Response]s and [Notification]s. | 9 * from, and to return both [Response]s and [Notification]s to, an analysis |
10 * server. | |
10 * | 11 * |
11 * Clients may not extend, implement or mix-in this class. | 12 * Clients may not extend, implement or mix-in this class. |
12 */ | 13 */ |
13 abstract class PluginCommunicationChannel { | 14 abstract class PluginCommunicationChannel { |
14 /** | 15 /** |
15 * Close the communication channel. | 16 * Close the communication channel. |
16 */ | 17 */ |
17 void close(); | 18 void close(); |
18 | 19 |
19 /** | 20 /** |
20 * Listen to the channel for requests. If a request is received, invoke the | 21 * Listen to the channel for requests. If a request is received, invoke the |
21 * [onRequest] function. If an error is encountered while trying to read from | 22 * [onRequest] function. If an error is encountered while trying to read from |
22 * the socket, invoke the [onError] function. If the socket is closed by the | 23 * the socket, invoke the [onError] function. If the socket is closed by the |
23 * client, invoke the [onDone] function. Only one listener is allowed per | 24 * client, invoke the [onDone] function. Only one listener is allowed per |
24 * channel. | 25 * channel. |
25 */ | 26 */ |
26 void listen(void onRequest(Request request), | 27 void listen(void onRequest(Request request), |
27 {Function onError, void onDone()}); | 28 {Function onError, void onDone()}); |
28 | 29 |
29 /** | 30 /** |
30 * Send the given [notification] to the server. | 31 * Send the given [notification] to the server. |
31 */ | 32 */ |
32 void sendNotification(Notification notification); | 33 void sendNotification(Notification notification); |
33 | 34 |
34 /** | 35 /** |
35 * Send the given [response] to the server. | 36 * Send the given [response] to the server. |
36 */ | 37 */ |
37 void sendResponse(Response response); | 38 void sendResponse(Response response); |
38 } | 39 } |
40 | |
41 /** | |
42 * A communication channel that allows an analysis server to send [Request]s | |
43 * to, and to receive both [Response]s and [Notification]s from, a plugin. | |
44 * | |
45 * Clients may not extend, implement or mix-in this class. | |
46 */ | |
47 abstract class ServerCommunicationChannel { | |
48 /** | |
49 * Close the communication channel. | |
50 */ | |
51 void close(); | |
52 | |
53 /** | |
54 * Listen to the channel for responses and notifications. If a response is | |
55 * received, invoke the [onResponse] function. If a notification is received, | |
56 * invoke the [onNotification] function. If an error is encountered while | |
57 * trying to read from the socket, invoke the [onError] function. If the | |
58 * socket is closed by the client, invoke the [onDone] function. Only one | |
scheglov
2017/02/02 18:25:04
Is "the client" here code that uses ServerCommunic
Brian Wilkerson
2017/02/02 18:46:39
The plugin. I'll fix the wording, thanks.
| |
59 * listener is allowed per channel. | |
60 */ | |
61 void listen(void onResponse(Response response), | |
62 void onNotification(Notification notification), | |
63 {Function onError, void onDone()}); | |
64 | |
65 /** | |
66 * Send the given [request] to the plugin. | |
67 */ | |
68 void sendRequest(Request request); | |
69 } | |
OLD | NEW |