| 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) { |
| 18 webSocket.pingInterval = const Duration(milliseconds: 100); |
| 19 webSocket.drain(); |
| 20 }); |
| 21 |
| 22 var futures = []; |
| 23 for (int i = 0; i < totalConnections; i++) { |
| 24 futures.add( |
| 25 WebSocket.connect('ws://localhost:${server.port}').then((webSocket) { |
| 26 webSocket.pingInterval = const Duration(milliseconds: 100); |
| 27 webSocket.drain(); |
| 28 new Timer(const Duration(seconds: 1), () { |
| 29 // Should not be closed yet. |
| 30 Expect.equals(null, webSocket.closeCode); |
| 31 webSocket.close(); |
| 32 }); |
| 33 return webSocket.done; |
| 34 })); |
| 35 } |
| 36 Future.wait(futures).then((_) => server.close()); |
| 37 }); |
| 38 } |
| 39 |
| 40 |
| 41 void main() { |
| 42 testPing(10); |
| 43 } |
| OLD | NEW |