OLD | NEW |
1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library messaging.utils; | 5 library messaging.utils; |
6 | 6 |
7 import 'dart:fletch'; | 7 import 'dart:dartino'; |
8 | 8 |
9 const int DEFAULT_MESSAGES = 1000; | 9 const int DEFAULT_MESSAGES = 1000; |
10 | 10 |
11 void channelResponder(Channel output) { | 11 void channelResponder(Channel output) { |
12 Channel input = new Channel(); | 12 Channel input = new Channel(); |
13 output.send(input); | 13 output.send(input); |
14 int message; | 14 int message; |
15 do { | 15 do { |
16 message = input.receive(); | 16 message = input.receive(); |
17 output.send(message - 1); | 17 output.send(message - 1); |
18 } while (message > 0); | 18 } while (message > 0); |
19 } | 19 } |
20 | 20 |
21 void portResponder(Port output) { | 21 void portResponder(Port output) { |
22 Channel input = new Channel(); | 22 Channel input = new Channel(); |
23 output.send(new Port(input)); | 23 output.send(new Port(input)); |
24 int message; | 24 int message; |
25 do { | 25 do { |
26 message = input.receive(); | 26 message = input.receive(); |
27 output.send(message - 1); | 27 output.send(message - 1); |
28 } while (message > 0); | 28 } while (message > 0); |
29 } | 29 } |
OLD | NEW |