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

Side by Side Diff: lib/src/client.dart

Issue 810333007: Add a done getter to Client, Server, and Peer. (Closed) Base URL: git@github.com:dart-lang/json_rpc_2@master
Patch Set: Created 5 years, 11 months 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
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/peer.dart » ('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.client; 5 library json_rpc_2.client;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
10 10
(...skipping 14 matching lines...) Expand all
25 25
26 /// The current batch of requests to be sent together. 26 /// The current batch of requests to be sent together.
27 /// 27 ///
28 /// Each element is a JSON-serializable object. 28 /// Each element is a JSON-serializable object.
29 List _batch; 29 List _batch;
30 30
31 /// The map of request ids for pending requests to [Completer]s that will be 31 /// The map of request ids for pending requests to [Completer]s that will be
32 /// completed with those requests' responses. 32 /// completed with those requests' responses.
33 final _pendingRequests = new Map<int, Completer>(); 33 final _pendingRequests = new Map<int, Completer>();
34 34
35 /// Returns a [Future] that completes when the connection is closed.
36 ///
37 /// This is the same future that's returned by [listen].
38 Future get done => _streams.done;
39
35 /// Creates a [Client] that writes requests to [requests] and reads responses 40 /// Creates a [Client] that writes requests to [requests] and reads responses
36 /// from [responses]. 41 /// from [responses].
37 /// 42 ///
38 /// If [responses] is a [StreamSink] as well as a [Stream] (for example, a 43 /// If [responses] is a [StreamSink] as well as a [Stream] (for example, a
39 /// `WebSocket`), [requests] may be omitted. 44 /// `WebSocket`), [requests] may be omitted.
40 /// 45 ///
41 /// Note that the client won't begin listening to [responses] until 46 /// Note that the client won't begin listening to [responses] until
42 /// [Client.listen] is called. 47 /// [Client.listen] is called.
43 Client(Stream<String> responses, [StreamSink<String> requests]) 48 Client(Stream<String> responses, [StreamSink<String> requests])
44 : _streams = new TwoWayStream( 49 : _streams = new TwoWayStream(
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 if (response.containsKey("result")) return true; 191 if (response.containsKey("result")) return true;
187 192
188 if (!response.containsKey("error")) return false; 193 if (!response.containsKey("error")) return false;
189 var error = response["error"]; 194 var error = response["error"];
190 if (error is! Map) return false; 195 if (error is! Map) return false;
191 if (error["code"] is! int) return false; 196 if (error["code"] is! int) return false;
192 if (error["message"] is! String) return false; 197 if (error["message"] is! String) return false;
193 return true; 198 return true;
194 } 199 }
195 } 200 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/peer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698