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

Side by Side Diff: runtime/bin/vmservice/server.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: error message 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 | « CHANGELOG.md ('k') | sdk/lib/io/websocket.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 vmservice_io; 5 part of vmservice_io;
6 6
7 class WebSocketClient extends Client { 7 class WebSocketClient extends Client {
8 static const int PARSE_ERROR_CODE = 4000; 8 static const int PARSE_ERROR_CODE = 4000;
9 static const int BINARY_MESSAGE_ERROR_CODE = 4001; 9 static const int BINARY_MESSAGE_ERROR_CODE = 4001;
10 static const int NOT_MAP_ERROR_CODE = 4002; 10 static const int NOT_MAP_ERROR_CODE = 4002;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // Do nothing. 50 // Do nothing.
51 return; 51 return;
52 } 52 }
53 try { 53 try {
54 if (result is String || result is Uint8List) { 54 if (result is String || result is Uint8List) {
55 socket.add(result); // String or binary message. 55 socket.add(result); // String or binary message.
56 } else { 56 } else {
57 // String message as external Uint8List. 57 // String message as external Uint8List.
58 assert(result is List); 58 assert(result is List);
59 Uint8List cstring = result[0]; 59 Uint8List cstring = result[0];
60 // TODO(rmacnak): cstring may be large. Add a way to pass an encoded 60 socket.addUtf8Text(cstring);
61 // string to a web socket that will be sent as a text message to avoid
62 // the space overhead of converting cstring to a Dart string.
63 socket.add(UTF8.decode(cstring));
64 } 61 }
65 } catch (_) { 62 } catch (_) {
66 print("Ignoring error posting over WebSocket."); 63 print("Ignoring error posting over WebSocket.");
67 } 64 }
68 } 65 }
69 66
70 dynamic toJson() { 67 dynamic toJson() {
71 Map map = super.toJson(); 68 Map map = super.toJson();
72 map['type'] = 'WebSocketClient'; 69 map['type'] = 'WebSocketClient';
73 map['socket'] = '$socket'; 70 map['socket'] = '$socket';
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 _notifyServerState("", 0); 318 _notifyServerState("", 0);
322 onServerAddressChange(null); 319 onServerAddressChange(null);
323 return this; 320 return this;
324 }); 321 });
325 } 322 }
326 323
327 } 324 }
328 325
329 void _notifyServerState(String ip, int port) 326 void _notifyServerState(String ip, int port)
330 native "VMServiceIO_NotifyServerState"; 327 native "VMServiceIO_NotifyServerState";
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | sdk/lib/io/websocket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698