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

Side by Side Diff: samples/chat/chat_server_lib.dart

Issue 10829459: Deprecate Math object in corelib in favor of dart:math library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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 | « samples/calculator/calculator.dart ('k') | samples/clock/balls.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #library("chat_server"); 5 #library("chat_server");
6 #import("dart:io"); 6 #import("dart:io");
7 #import("dart:isolate"); 7 #import("dart:isolate");
8 #import("dart:json"); 8 #import("dart:json");
9 #import("dart:math");
9 10
10 void startChatServer() { 11 void startChatServer() {
11 var server = new ChatServer(); 12 var server = new ChatServer();
12 server.init(); 13 server.init();
13 port.receive(server.dispatch); 14 port.receive(server.dispatch);
14 } 15 }
15 16
16 class ChatServer extends IsolatedServer { 17 class ChatServer extends IsolatedServer {
17 } 18 }
18 19
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 51 }
51 52
52 ReceivePort _statusPort; // Port for receiving messages from the server. 53 ReceivePort _statusPort; // Port for receiving messages from the server.
53 SendPort _serverPort; // Port for sending messages to the server. 54 SendPort _serverPort; // Port for sending messages to the server.
54 } 55 }
55 56
56 57
57 class User { 58 class User {
58 User(this._handle) { 59 User(this._handle) {
59 // TODO(sgjesse) Generate more secure and unique session id's. 60 // TODO(sgjesse) Generate more secure and unique session id's.
60 _sessionId = "a${(Math.random() * 1000000).toInt()}"; 61 var rand = new Random();
62 _sessionId = "a${rand.nextInt(1000000)}";
61 markActivity(); 63 markActivity();
62 } 64 }
63 65
64 void markActivity() { _lastActive = new Date.now(); } 66 void markActivity() { _lastActive = new Date.now(); }
65 Duration idleTime(Date now) => now.difference(_lastActive); 67 Duration idleTime(Date now) => now.difference(_lastActive);
66 68
67 String get handle() => _handle; 69 String get handle() => _handle;
68 String get sessionId() => _sessionId; 70 String get sessionId() => _sessionId;
69 71
70 String _handle; 72 String _handle;
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 684 }
683 } 685 }
684 686
685 int _timeRange; 687 int _timeRange;
686 List<int> _buckets; 688 List<int> _buckets;
687 int _currentBucket; 689 int _currentBucket;
688 int _currentBucketTime; 690 int _currentBucketTime;
689 num _bucketTimeRange; 691 num _bucketTimeRange;
690 int _sum; 692 int _sum;
691 } 693 }
OLDNEW
« no previous file with comments | « samples/calculator/calculator.dart ('k') | samples/clock/balls.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698