Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: pkg/json_rpc_2/lib/src/server.dart

Issue 707063002: Add a Peer class to json_rpc_2. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/json_rpc_2/lib/src/peer.dart ('k') | pkg/json_rpc_2/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « pkg/json_rpc_2/lib/src/peer.dart ('k') | pkg/json_rpc_2/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698