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

Side by Side Diff: lib/src/peer.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 | « lib/src/client.dart ('k') | lib/src/server.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.peer; 5 library json_rpc_2.peer;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../error_code.dart' as error_code; 9 import '../error_code.dart' as error_code;
10 import 'client.dart'; 10 import 'client.dart';
(...skipping 23 matching lines...) Expand all
34 final _serverIncomingForwarder = new StreamController(sync: true); 34 final _serverIncomingForwarder = new StreamController(sync: true);
35 35
36 /// A stream controller that forwards incoming messages to [_client] if 36 /// A stream controller that forwards incoming messages to [_client] if
37 /// they're responses. 37 /// they're responses.
38 final _clientIncomingForwarder = new StreamController(sync: true); 38 final _clientIncomingForwarder = new StreamController(sync: true);
39 39
40 /// A stream controller that forwards outgoing messages from both [_server] 40 /// A stream controller that forwards outgoing messages from both [_server]
41 /// and [_client]. 41 /// and [_client].
42 final _outgoingForwarder = new StreamController(sync: true); 42 final _outgoingForwarder = new StreamController(sync: true);
43 43
44 Future get done => _streams.done;
45
44 /// Creates a [Peer] that reads incoming messages from [incoming] and writes 46 /// Creates a [Peer] that reads incoming messages from [incoming] and writes
45 /// outgoing messages to [outgoing]. 47 /// outgoing messages to [outgoing].
46 /// 48 ///
47 /// If [incoming] is a [StreamSink] as well as a [Stream] (for example, a 49 /// If [incoming] is a [StreamSink] as well as a [Stream] (for example, a
48 /// `WebSocket`), [outgoing] may be omitted. 50 /// `WebSocket`), [outgoing] may be omitted.
49 /// 51 ///
50 /// Note that the peer won't begin listening to [incoming] until [Peer.listen] 52 /// Note that the peer won't begin listening to [incoming] until [Peer.listen]
51 /// is called. 53 /// is called.
52 Peer(Stream<String> incoming, [StreamSink<String> outgoing]) { 54 Peer(Stream<String> incoming, [StreamSink<String> outgoing]) {
53 _streams = new TwoWayStream("Peer", incoming, "incoming", 55 _streams = new TwoWayStream("Peer", incoming, "incoming",
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // Non-Map and -List messages are ill-formed, so we pass them to the 129 // Non-Map and -List messages are ill-formed, so we pass them to the
128 // server since it knows how to send error responses. 130 // server since it knows how to send error responses.
129 _serverIncomingForwarder.add(message); 131 _serverIncomingForwarder.add(message);
130 } 132 }
131 }); 133 });
132 } 134 }
133 135
134 Future close() => 136 Future close() =>
135 Future.wait([_client.close(), _server.close(), _streams.close()]); 137 Future.wait([_client.close(), _server.close(), _streams.close()]);
136 } 138 }
OLDNEW
« no previous file with comments | « lib/src/client.dart ('k') | lib/src/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698