OLD | NEW |
1 #!mojo mojo:dart_content_handler | 1 #!mojo mojo:dart_content_handler |
2 // Copyright 2015 The Chromium Authors. All rights reserved. | 2 // Copyright 2015 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 // To run this app: | 6 // To run this app: |
7 // mojo_shell mojo:hello | 7 // mojo_shell mojo:hello |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 | 10 |
11 import 'package:mojo/application.dart'; | 11 import 'package:mojo/application.dart'; |
12 import 'package:mojo/bindings.dart'; | 12 import 'package:mojo/bindings.dart'; |
13 import 'package:mojo/core.dart'; | 13 import 'package:mojo/core.dart'; |
14 | 14 |
15 class Hello extends Application { | 15 class Hello extends Application { |
16 Hello.fromHandle(MojoHandle handle) : super.fromHandle(handle); | 16 Hello.fromHandle(MojoHandle handle) : super.fromHandle(handle); |
17 | 17 |
18 void initialize(List<String> args, String url) { | 18 void initialize(List<String> args, String url) { |
19 print("$url Hello"); | 19 print("$url Hello"); |
20 | 20 |
| 21 var worldUrl = url.replaceAll("hello", "world"); |
| 22 print("Connecting to $worldUrl"); |
| 23 |
21 // We expect to find the world mojo application at the same | 24 // We expect to find the world mojo application at the same |
22 // path as this application. | 25 // path as this application. |
23 var c = connectToApplication(url.replaceAll("hello", "world")); | 26 var c = connectToApplication(worldUrl); |
24 | 27 |
25 // A call to close() here would cause this app to go down before the "world" | 28 // A call to close() here would cause this app to go down before the "world" |
26 // app has a chance to come up. Instead, we wait to close this app until | 29 // app has a chance to come up. Instead, we wait to close this app until |
27 // the "world" app comes up, does its print, and closes its end of the | 30 // the "world" app comes up, does its print, and closes its end of the |
28 // connection. | 31 // connection. |
29 c.onError = closeApplication; | 32 c.onError = closeApplication; |
30 } | 33 } |
31 | 34 |
32 Future closeApplication(e) async { | 35 Future closeApplication(e) async { |
33 await close(); | 36 await close(); |
34 MojoHandle.reportLeakedHandles(); | 37 MojoHandle.reportLeakedHandles(); |
35 } | 38 } |
36 } | 39 } |
37 | 40 |
38 main(List args) { | 41 main(List args) { |
39 MojoHandle appHandle = new MojoHandle(args[0]); | 42 MojoHandle appHandle = new MojoHandle(args[0]); |
40 new Hello.fromHandle(appHandle); | 43 new Hello.fromHandle(appHandle); |
41 } | 44 } |
OLD | NEW |