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

Side by Side Diff: tests/standalone/io/web_socket_ping_test.dart

Issue 19970004: Add ability to send a ping interval on a WebSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix comment and add missing test. Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698