Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 // | |
| 5 // VMOptions= | |
| 6 // VMOptions=--short_socket_read | |
| 7 // VMOptions=--short_socket_write | |
| 8 // VMOptions=--short_socket_read --short_socket_write | |
| 9 | |
| 10 import "package:expect/expect.dart"; | |
| 11 import "dart:async"; | |
| 12 import "dart:io"; | |
| 13 | |
| 14 | |
| 15 void testPing(int totalConnections) { | |
| 16 HttpServer.bind('localhost', 0).then((server) { | |
| 17 server.transform(new WebSocketTransformer()).listen((webSocket) { | |
|
Søren Gjesse
2013/07/24 12:31:28
Set a pingInterval on the server side as well.
Anders Johnsen
2013/07/24 12:51:02
Done.
| |
| 18 webSocket.drain(); | |
| 19 }); | |
| 20 | |
| 21 var futures = []; | |
| 22 for (int i = 0; i < totalConnections; i++) { | |
| 23 futures.add( | |
| 24 WebSocket.connect('ws://localhost:${server.port}').then((webSocket) { | |
| 25 webSocket.pingInterval = const Duration(milliseconds: 200); | |
| 26 webSocket.drain(); | |
| 27 new Timer(const Duration(seconds: 1), () { | |
| 28 // Should not be closed yet. | |
| 29 Expect.equals(null, webSocket.closeCode); | |
| 30 webSocket.close(); | |
| 31 }); | |
| 32 return webSocket.done; | |
| 33 })); | |
| 34 } | |
| 35 Future.wait(futures).then((_) => server.close()); | |
| 36 }); | |
| 37 } | |
| 38 | |
| 39 | |
| 40 void main() { | |
| 41 testPing(10); | |
| 42 } | |
| OLD | NEW |