| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 import 'dart:async'; | |
| 6 | |
| 7 import 'package:mojo/application.dart'; | |
| 8 import 'package:mojo/bindings.dart'; | |
| 9 import 'package:mojo/core.dart'; | |
| 10 import 'package:_mojo_for_test_only/test/echo_service.mojom.dart'; | |
| 11 | |
| 12 class EchoServiceImpl implements EchoService { | |
| 13 EchoServiceStub _stub; | |
| 14 Application _application; | |
| 15 | |
| 16 EchoServiceImpl(this._application, MojoMessagePipeEndpoint endpoint) { | |
| 17 _stub = new EchoServiceStub.fromEndpoint(endpoint, this); | |
| 18 } | |
| 19 | |
| 20 dynamic echoString(String value, [Function responseFactory]) { | |
| 21 if (value == "quit") { | |
| 22 _stub.close(); | |
| 23 } | |
| 24 return responseFactory(value); | |
| 25 } | |
| 26 | |
| 27 dynamic delayedEchoString(String value, int millis, | |
| 28 [Function responseFactory]) { | |
| 29 if (value == "quit") { | |
| 30 _stub.close(); | |
| 31 } | |
| 32 return new Future.delayed( | |
| 33 new Duration(milliseconds: millis), () => responseFactory(value)); | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 class EchoApplication extends Application { | |
| 38 EchoApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle); | |
| 39 | |
| 40 @override | |
| 41 void acceptConnection(String requestorUrl, String resolvedUrl, | |
| 42 ApplicationConnection connection) { | |
| 43 connection.provideService( | |
| 44 EchoService.serviceName, (endpoint) => new EchoServiceImpl(this, endpoin
t)); | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 main(List args) { | |
| 49 MojoHandle appHandle = new MojoHandle(args[0]); | |
| 50 String url = args[1]; | |
| 51 new EchoApplication.fromHandle(appHandle) | |
| 52 ..onError = ((_) { | |
| 53 MojoHandle.reportLeakedHandles(); | |
| 54 }); | |
| 55 } | |
| OLD | NEW |