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

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

Issue 1756613002: Add an IO implementation of WebSocketChannel. (Closed) Base URL: git@github.com:dart-lang/web_socket_channel.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:async/async.dart'; 7 import 'package:async/async.dart';
8 import 'package:crypto/crypto.dart'; 8 import 'package:crypto/crypto.dart';
9 import 'package:stream_channel/stream_channel.dart'; 9 import 'package:stream_channel/stream_channel.dart';
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 Stream get stream => new StreamView(_webSocket); 64 Stream get stream => new StreamView(_webSocket);
65 65
66 /// The sink for sending values to the other endpoint. 66 /// The sink for sending values to the other endpoint.
67 /// 67 ///
68 /// This supports additional arguments to [WebSocketSink.close] that provide 68 /// This supports additional arguments to [WebSocketSink.close] that provide
69 /// the remote endpoint reasons for closing the connection. 69 /// the remote endpoint reasons for closing the connection.
70 WebSocketSink get sink => new WebSocketSink._(_webSocket); 70 WebSocketSink get sink => new WebSocketSink._(_webSocket);
71 71
72 /// Signs a `Sec-WebSocket-Key` header sent by a WebSocket client as part of 72 /// Signs a `Sec-WebSocket-Key` header sent by a WebSocket client as part of
73 /// the [initial handshake]. 73 /// the [initial handshake][].
74 /// 74 ///
75 /// The return value should be sent back to the client in a 75 /// The return value should be sent back to the client in a
76 /// `Sec-WebSocket-Accept` header. 76 /// `Sec-WebSocket-Accept` header.
77 /// 77 ///
78 /// [initial handshake]: https://tools.ietf.org/html/rfc6455#section-4.2.2 78 /// [initial handshake]: https://tools.ietf.org/html/rfc6455#section-4.2.2
79 static String signKey(String key) { 79 static String signKey(String key) {
80 var hash = new SHA1(); 80 var hash = new SHA1();
81 // We use [codeUnits] here rather than UTF-8-decoding the string because 81 // We use [codeUnits] here rather than UTF-8-decoding the string because
82 // [key] is expected to be base64 encoded, and so will be pure ASCII. 82 // [key] is expected to be base64 encoded, and so will be pure ASCII.
83 hash.add((key + webSocketGUID).codeUnits); 83 hash.add((key + webSocketGUID).codeUnits);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 /// 118 ///
119 /// [closeCode] and [closeReason] are the [close code][] and [reason][] sent 119 /// [closeCode] and [closeReason] are the [close code][] and [reason][] sent
120 /// to the remote peer, respectively. If they are omitted, the peer will see 120 /// to the remote peer, respectively. If they are omitted, the peer will see
121 /// a "no status received" code with no reason. 121 /// a "no status received" code with no reason.
122 /// 122 ///
123 /// [close code]: https://tools.ietf.org/html/rfc6455#section-7.1.5 123 /// [close code]: https://tools.ietf.org/html/rfc6455#section-7.1.5
124 /// [reason]: https://tools.ietf.org/html/rfc6455#section-7.1.6 124 /// [reason]: https://tools.ietf.org/html/rfc6455#section-7.1.6
125 Future close([int closeCode, String closeReason]) => 125 Future close([int closeCode, String closeReason]) =>
126 _webSocket.close(closeCode, closeReason); 126 _webSocket.close(closeCode, closeReason);
127 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698