OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.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 pub_tests; | 5 library pub_tests; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 | 10 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 return WebSocket.connect("ws://localhost:$_adminPort").then((socket) { | 337 return WebSocket.connect("ws://localhost:$_adminPort").then((socket) { |
338 _webSocket = socket; | 338 _webSocket = socket; |
339 // TODO(rnystrom): Works around #13913. | 339 // TODO(rnystrom): Works around #13913. |
340 _webSocketBroadcastStream = _webSocket.map(JSON.decode).asBroadcastStream(); | 340 _webSocketBroadcastStream = _webSocket.map(JSON.decode).asBroadcastStream(); |
341 }); | 341 }); |
342 } | 342 } |
343 | 343 |
344 /// Schedules closing the web socket connection to the currently-running pub | 344 /// Schedules closing the web socket connection to the currently-running pub |
345 /// serve. | 345 /// serve. |
346 Future closeWebSocket() { | 346 void closeWebSocket() { |
347 schedule(() { | 347 schedule(() { |
348 return _ensureWebSocket().then((_) => _webSocket.close()) | 348 return _ensureWebSocket().then((_) => _webSocket.close()) |
349 .then((_) => _webSocket = null); | 349 .then((_) => _webSocket = null); |
350 }, "closing web socket"); | 350 }, "closing web socket"); |
351 } | 351 } |
352 | 352 |
353 /// Sends a JSON RPC 2.0 request to the running pub serve's web socket | 353 /// Sends a JSON RPC 2.0 request to the running pub serve's web socket |
354 /// connection. | 354 /// connection. |
355 /// | 355 /// |
356 /// This calls a method named [method] with the given [params] (or no | 356 /// This calls a method named [method] with the given [params] (or no |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 /// included. Unlike [getServerUrl], this should only be called after the ports | 490 /// included. Unlike [getServerUrl], this should only be called after the ports |
491 /// are known. | 491 /// are known. |
492 String _getServerUrlSync([String root, String path]) { | 492 String _getServerUrlSync([String root, String path]) { |
493 if (root == null) root = 'web'; | 493 if (root == null) root = 'web'; |
494 expect(_ports, contains(root)); | 494 expect(_ports, contains(root)); |
495 var url = "http://localhost:${_ports[root]}"; | 495 var url = "http://localhost:${_ports[root]}"; |
496 if (path != null) url = "$url/$path"; | 496 if (path != null) url = "$url/$path"; |
497 return url; | 497 return url; |
498 } | 498 } |
499 | 499 |
OLD | NEW |