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

Side by Side Diff: sdk/lib/io/websocket.dart

Issue 2260073002: RFC: Sending pre-encoded text over a web socket. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: . Created 4 years, 4 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 | « runtime/bin/vmservice/server.dart ('k') | sdk/lib/io/websocket_impl.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * WebSocket status codes used when closing a WebSocket connection. 8 * WebSocket status codes used when closing a WebSocket connection.
9 */ 9 */
10 abstract class WebSocketStatus { 10 abstract class WebSocketStatus {
11 static const int NORMAL_CLOSURE = 1000; 11 static const int NORMAL_CLOSURE = 1000;
12 static const int GOING_AWAY = 1001; 12 static const int GOING_AWAY = 1001;
13 static const int PROTOCOL_ERROR = 1002; 13 static const int PROTOCOL_ERROR = 1002;
14 static const int UNSUPPORTED_DATA = 1003; 14 static const int UNSUPPORTED_DATA = 1003;
15 static const int RESERVED_1004 = 1004; 15 static const int RESERVED_1004 = 1004;
16 static const int NO_STATUS_RECEIVED = 1005; 16 static const int NO_STATUS_RECEIVED = 1005;
17 static const int ABNORMAL_CLOSURE = 1006; 17 static const int ABNORMAL_CLOSURE = 1006;
18 static const int INVALID_FRAME_PAYLOAD_DATA = 1007; 18 static const int INVALID_FRAME_PAYLOAD_DATA = 1007;
19 static const int POLICY_VIOLATION = 1008; 19 static const int POLICY_VIOLATION = 1008;
20 static const int MESSAGE_TOO_BIG = 1009; 20 static const int MESSAGE_TOO_BIG = 1009;
21 static const int MISSING_MANDATORY_EXTENSION = 1010; 21 static const int MISSING_MANDATORY_EXTENSION = 1010;
22 static const int INTERNAL_SERVER_ERROR = 1011; 22 static const int INTERNAL_SERVER_ERROR = 1011;
23 static const int RESERVED_1015 = 1015; 23 static const int RESERVED_1015 = 1015;
24 } 24 }
25 25
26
27 /**
28 * WebSocket message types used for [WebSocket.sendMessage].
29 */
30 enum WebSocketMessageType {
31 TEXT,
32 BINARY
33 }
34
35
26 /** 36 /**
27 * The [CompressionOptions] class allows you to control 37 * The [CompressionOptions] class allows you to control
28 * the options of WebSocket compression. 38 * the options of WebSocket compression.
29 */ 39 */
30 class CompressionOptions { 40 class CompressionOptions {
31 /** 41 /**
32 * Default WebSocket Compression options. 42 * Default WebSocket Compression options.
33 * Compression will be enabled with the following options: 43 * Compression will be enabled with the following options:
34 * clientNoContextTakeover: false 44 * clientNoContextTakeover: false
35 * serverNoContextTakeover: false 45 * serverNoContextTakeover: false
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 * be either a `String`, or a `List<int>` holding bytes. 405 * be either a `String`, or a `List<int>` holding bytes.
396 */ 406 */
397 void add(/*String|List<int>*/ data); 407 void add(/*String|List<int>*/ data);
398 408
399 /** 409 /**
400 * Sends data from a stream on WebSocket connection. Each data event from 410 * Sends data from a stream on WebSocket connection. Each data event from
401 * [stream] will be send as a single WebSocket frame. The data from [stream] 411 * [stream] will be send as a single WebSocket frame. The data from [stream]
402 * must be either `String`s, or `List<int>`s holding bytes. 412 * must be either `String`s, or `List<int>`s holding bytes.
403 */ 413 */
404 Future addStream(Stream stream); 414 Future addStream(Stream stream);
415
416 /**
417 * Sends a binary message or a pre-encoded text message.
418 */
419 void sendMessage(WebSocketMessageType type, List<int> bytes);
Lasse Reichstein Nielsen 2016/08/24 05:10:12 For consistency, the name should start with "add".
Lasse Reichstein Nielsen 2016/08/24 05:51:04 Or maybe addUtf8Text - it seems that WebSockets ta
Cutch 2016/08/24 14:01:41 According to the spec https://tools.ietf.org/html/
Lasse Reichstein Nielsen 2016/08/24 14:16:47 That's a perfectly reasonable response, and it sho
405 } 420 }
406 421
407 class WebSocketException implements IOException { 422 class WebSocketException implements IOException {
408 final String message; 423 final String message;
409 424
410 const WebSocketException([this.message = ""]); 425 const WebSocketException([this.message = ""]);
411 426
412 String toString() => "WebSocketException: $message"; 427 String toString() => "WebSocketException: $message";
413 } 428 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/server.dart ('k') | sdk/lib/io/websocket_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698