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 json_rpc_2.server; | 5 library json_rpc_2.server; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 /// | 62 /// |
63 /// If [requests] is a [StreamSink] as well as a [Stream], [responses] may be | 63 /// If [requests] is a [StreamSink] as well as a [Stream], [responses] may be |
64 /// omitted. | 64 /// omitted. |
65 /// | 65 /// |
66 /// Note that the server won't begin listening to [requests] until | 66 /// Note that the server won't begin listening to [requests] until |
67 /// [Server.listen] is called. | 67 /// [Server.listen] is called. |
68 Server.withoutJson(Stream requests, [StreamSink responses]) | 68 Server.withoutJson(Stream requests, [StreamSink responses]) |
69 : _streams = new TwoWayStream.withoutJson( | 69 : _streams = new TwoWayStream.withoutJson( |
70 "Server", requests, "requests", responses, "responses"); | 70 "Server", requests, "requests", responses, "responses"); |
71 | 71 |
72 /// Users of the library should not use this constructor. | |
73 Server.internal(this._streams); | |
74 | |
75 /// Starts listening to the underlying stream. | 72 /// Starts listening to the underlying stream. |
76 /// | 73 /// |
77 /// Returns a [Future] that will complete when the stream is closed or when it | 74 /// Returns a [Future] that will complete when the stream is closed or when it |
78 /// has an error. | 75 /// has an error. |
79 /// | 76 /// |
80 /// [listen] may only be called once. | 77 /// [listen] may only be called once. |
81 Future listen() => _streams.listen(_handleRequest); | 78 Future listen() => _streams.listen(_handleRequest); |
82 | 79 |
83 /// Closes the server's request subscription and response sink. | 80 /// Closes the server's request subscription and response sink. |
84 /// | 81 /// |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 return syncFuture(() => iterator.current(params)).catchError((error) { | 237 return syncFuture(() => iterator.current(params)).catchError((error) { |
241 if (error is! RpcException) throw error; | 238 if (error is! RpcException) throw error; |
242 if (error.code != error_code.METHOD_NOT_FOUND) throw error; | 239 if (error.code != error_code.METHOD_NOT_FOUND) throw error; |
243 return _tryNext(); | 240 return _tryNext(); |
244 }); | 241 }); |
245 } | 242 } |
246 | 243 |
247 return _tryNext(); | 244 return _tryNext(); |
248 } | 245 } |
249 } | 246 } |
OLD | NEW |