OLD | NEW |
(Empty) | |
| 1 #!mojo:js_content_handler |
| 2 // Demonstrate one JS Mojo application connecting to another to emit "hello |
| 3 // world". To run this application with mojo_shell, set DIR to be the absolute |
| 4 // path for this directory, then: |
| 5 // mojo_shell "file://$DIR/hello.js file://$DIR/world.js" |
| 6 // Launches the Mojo hello.js application which connects to the application |
| 7 // URL specified as a Mojo application argument, world.js in this case. |
| 8 |
| 9 define("main", [ |
| 10 "console", |
| 11 "mojo/public/interfaces/application/service_provider.mojom", |
| 12 ], function(console, sp) { |
| 13 |
| 14 function Application(shell, url) { |
| 15 this.shell = shell; |
| 16 console.log(url + ": Hello"); |
| 17 } |
| 18 |
| 19 Application.prototype.initialize = function(args) { |
| 20 if (args.length != 2) { |
| 21 console.log("Expected hello.js URL argument"); |
| 22 return; |
| 23 } |
| 24 var serviceProvider = new sp.ServiceProvider.proxyClass(); |
| 25 // TODO(hansmuller): the following step shouldn't be necessary. |
| 26 var handle = serviceProvider.getConnection$().messagePipeHandle; |
| 27 this.shell.connectToApplication(args[1], handle); |
| 28 } |
| 29 |
| 30 Application.prototype.acceptConnection = function(url, serviceProvider) { |
| 31 } |
| 32 |
| 33 return Application; |
| 34 }); |
OLD | NEW |