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

Side by Side Diff: samples/socket/SocketExample.dart

Issue 8992007: Make the repeating argument to timers optional. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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 | « samples/chat/chat_server.dart ('k') | tests/standalone/src/MultipleTimerTest.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Shows how to use Socket, ServerSocket and InputStream. 6 * Shows how to use Socket, ServerSocket and InputStream.
7 * 7 *
8 * (This deliberately sends data slowly, to show how InputStream can be 8 * (This deliberately sends data slowly, to show how InputStream can be
9 * read from asynchronously.) 9 * read from asynchronously.)
10 */ 10 */
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 // send next 4 bytes slowly 48 // send next 4 bytes slowly
49 new Timer((Timer t) { 49 new Timer((Timer t) {
50 sendByte(); 50 sendByte();
51 if (bytesSent == bytesTotal) { 51 if (bytesSent == bytesTotal) {
52 sendSocket.close(); 52 sendSocket.close();
53 t.cancel(); 53 t.cancel();
54 print("finished sending"); 54 print("finished sending");
55 } 55 }
56 }, 500, true ); 56 }, 500, true);
Søren Gjesse 2011/12/19 12:10:45 Maybe "repeating: true" here and in places where t
57 } 57 }
58 58
59 void onConnect(Socket connection) { 59 void onConnect(Socket connection) {
60 receiveSocket = connection; 60 receiveSocket = connection;
61 inputStream = receiveSocket.inputStream; 61 inputStream = receiveSocket.inputStream;
62 inputStream.dataHandler = receiveBytes; 62 inputStream.dataHandler = receiveBytes;
63 } 63 }
64 64
65 void sendByte() { 65 void sendByte() {
66 sendSocket.writeList(const [65], 0, 1); 66 sendSocket.writeList(const [65], 0, 1);
(...skipping 11 matching lines...) Expand all
78 print("received ${numBytes} bytes (${bytesReceived} bytes total)"); 78 print("received ${numBytes} bytes (${bytesReceived} bytes total)");
79 if (bytesReceived >= bytesTotal) { 79 if (bytesReceived >= bytesTotal) {
80 receiveSocket.close(); 80 receiveSocket.close();
81 serverSocket.close(); 81 serverSocket.close();
82 print("done"); 82 print("done");
83 } 83 }
84 } 84 }
85 } 85 }
86 86
87 void main() => new SocketExample().go(); 87 void main() => new SocketExample().go();
OLDNEW
« no previous file with comments | « samples/chat/chat_server.dart ('k') | tests/standalone/src/MultipleTimerTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698