OLD | NEW |
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 part of dartcombatlib; | 5 part of dartcombatlib; |
6 | 6 |
7 /** Entrypoint to set up the dartcombat sample. */ | 7 /** Entrypoint to set up the dartcombat sample. */ |
8 void setUpGame() { | 8 void setUpGame() { |
9 setupUI(); | 9 setupUI(); |
10 createPlayers(); | 10 createPlayers(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ReceivePort proxy; | 73 ReceivePort proxy; |
74 | 74 |
75 SendPort _target; | 75 SendPort _target; |
76 | 76 |
77 SendPort get sendPort => proxy.toSendPort(); | 77 SendPort get sendPort => proxy.toSendPort(); |
78 | 78 |
79 FlakyProxy(this._target) { | 79 FlakyProxy(this._target) { |
80 proxy = new ReceivePort(); | 80 proxy = new ReceivePort(); |
81 | 81 |
82 proxy.receive((message, SendPort reply) { | 82 proxy.receive((message, SendPort reply) { |
83 window.setTimeout(() { | 83 new Timer(const Duration(milliseconds: 200), () { |
84 if (randomlyFail()) { | 84 if (randomlyFail()) { |
85 reply.send(const [false, "There was an error"], null); | 85 reply.send(const [false, "There was an error"], null); |
86 } else { | 86 } else { |
87 _target.send(message, reply); | 87 _target.send(message, reply); |
88 } | 88 } |
89 }, 200); | 89 }); |
90 }); | 90 }); |
91 } | 91 } |
92 | 92 |
93 // TODO(sigmund): introduce UI to control flakiness, then do: | 93 // TODO(sigmund): introduce UI to control flakiness, then do: |
94 // => Math.random() > 0.9; | 94 // => Math.random() > 0.9; |
95 bool randomlyFail() => false; | 95 bool randomlyFail() => false; |
96 } | 96 } |
OLD | NEW |