OLD | NEW |
(Empty) | |
| 1 #!mojo mojo:dart_content_handler |
| 2 |
| 3 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 4 // Use of this source code is governed by a BSD-style license that can be |
| 5 // found in the LICENSE file. |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'dart:mojo_application'; |
| 9 import 'dart:mojo_bindings'; |
| 10 import 'dart:mojo_core'; |
| 11 |
| 12 import 'package:services/dart/test/echo_service.mojom.dart'; |
| 13 |
| 14 // TODO(zra): Interface implementations that delegate to another implementation |
| 15 // will all look the same, more or less. Maybe we should generate them? |
| 16 class EchoServiceImpl extends EchoServiceInterface { |
| 17 EchoServiceInterface _delegate; |
| 18 |
| 19 EchoServiceImpl(this._delegate, MojoMessagePipeEndpoint endpoint) : |
| 20 super(endpoint); |
| 21 |
| 22 echoString(String value) => _delegate.echoString(value); |
| 23 } |
| 24 |
| 25 class EchoApplication extends Application implements EchoServiceInterface { |
| 26 EchoApplication(MojoMessagePipeEndpoint endpoint) : super(endpoint); |
| 27 |
| 28 EchoApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle); |
| 29 |
| 30 Function interfaceFactoryClosure() { |
| 31 return (endpoint) => new EchoServiceImpl(this, endpoint); |
| 32 } |
| 33 |
| 34 echoString(String value) { |
| 35 var response = new EchoServiceEchoStringResponseParams(); |
| 36 if (value == 'quit') { |
| 37 close(); |
| 38 } |
| 39 response.value = value; |
| 40 return new Future.value(response); |
| 41 } |
| 42 } |
| 43 |
| 44 main(List args) { |
| 45 MojoHandle shellHandle = new MojoHandle(args[0]); |
| 46 String url = args[1]; |
| 47 var echoApplication = new EchoApplication.fromHandle(shellHandle); |
| 48 echoApplication.listen(); |
| 49 } |
OLD | NEW |