| Index: services/dart/test/pingpong/main.dart
|
| diff --git a/services/dart/test/pingpong/main.dart b/services/dart/test/pingpong/main.dart
|
| index 40f53057a56b84764586c609e274791b4e5c424e..df08346ae704ff9f7d67d6efbc0deb3fad20cec0 100644
|
| --- a/services/dart/test/pingpong/main.dart
|
| +++ b/services/dart/test/pingpong/main.dart
|
| @@ -9,39 +9,45 @@ import 'mojo:core';
|
|
|
| import 'package:services/dart/test/pingpong_service.mojom.dart';
|
|
|
| -class PingPongClientImpl extends PingPongClient {
|
| +class PingPongClientImpl implements PingPongClient {
|
| + final PingPongClientStub stub;
|
| Completer _completer;
|
| int _count;
|
|
|
| - PingPongClientImpl.unbound(this._count, this._completer) : super.unbound() {
|
| - super.delegate = this;
|
| + PingPongClientImpl.unbound(this._count, this._completer)
|
| + : stub = new PingPongClientStub.unbound() {
|
| + stub.delegate = this;
|
| }
|
|
|
| void pong(int pongValue) {
|
| if (pongValue == _count) {
|
| _completer.complete(null);
|
| - close();
|
| + stub.close();
|
| }
|
| }
|
| }
|
|
|
| -class PingPongServiceImpl extends PingPongService {
|
| +class PingPongServiceImpl implements PingPongService {
|
| + PingPongServiceStub _stub;
|
| Application _application;
|
| PingPongClientProxy _proxy;
|
|
|
| PingPongServiceImpl(Application application, MojoMessagePipeEndpoint endpoint)
|
| - : _application = application, super(endpoint) {
|
| - super.delegate = this;
|
| + : _application = application {
|
| + _stub = new PingPongServiceStub.fromEndpoint(endpoint)
|
| + ..delegate = this
|
| + ..listen();
|
| }
|
|
|
| - PingPongServiceImpl.fromStub(PingPongServiceStub stub)
|
| - : super.fromStub(stub) {
|
| - super.delegate = this;
|
| + PingPongServiceImpl.fromStub(this._stub) {
|
| + _stub.delegate = this;
|
| }
|
|
|
| - void setClient(PingPongClientProxy proxy) {
|
| + listen() => _stub.listen();
|
| +
|
| + void setClient(Proxy proxy) {
|
| assert(_proxy == null);
|
| - _proxy = proxy;
|
| + _proxy = new PingPongClientProxy(proxy);
|
| }
|
|
|
| void ping(int pingValue) {
|
| @@ -50,17 +56,17 @@ class PingPongServiceImpl extends PingPongService {
|
| }
|
| }
|
|
|
| - pingTargetUrl(String url, int count, Function responseFactory) async {
|
| + Future pingTargetUrl(String url, int count, Function responseFactory) async {
|
| if (_application == null) {
|
| return responseFactory(false);
|
| }
|
| var completer = new Completer();
|
| var pingPongService = new PingPongServiceProxy.unbound();
|
| - _application.connectToService(url, pingPongService);
|
| + _application.connectToService(url, PingPongServiceRequest(pingPongService));
|
|
|
| var pingPongClient = new PingPongClientImpl.unbound(count, completer);
|
| pingPongService.setClient(pingPongClient.stub);
|
| - pingPongClient.listen();
|
| + pingPongClient.stub.listen();
|
|
|
| for (var i = 0; i < count; i++) {
|
| pingPongService.ping(i);
|
| @@ -71,13 +77,14 @@ class PingPongServiceImpl extends PingPongService {
|
| return responseFactory(true);
|
| }
|
|
|
| - pingTargetService(PingPongServiceProxy pingPongService,
|
| - int count,
|
| - Function responseFactory) async {
|
| + Future pingTargetService(Proxy proxy,
|
| + int count,
|
| + Function responseFactory) async {
|
| + var pingPongService = new PingPongServiceProxy(proxy);
|
| var completer = new Completer();
|
| var client = new PingPongClientImpl.unbound(count, completer);
|
| pingPongService.setClient(client.stub);
|
| - client.listen();
|
| + client.stub.listen();
|
|
|
| for (var i = 0; i < count; i++) {
|
| pingPongService.ping(i);
|
| @@ -89,15 +96,14 @@ class PingPongServiceImpl extends PingPongService {
|
| }
|
|
|
| getPingPongService(PingPongServiceStub serviceStub) {
|
| - var pingPongService = new PingPongServiceImpl.fromStub(serviceStub);
|
| - pingPongService.listen();
|
| + new PingPongServiceImpl.fromStub(serviceStub)..listen();
|
| }
|
|
|
| void quit() {
|
| if (_proxy != null) {
|
| - _proxy.close();
|
| + PingPongClientProxyClose(_proxy);
|
| }
|
| - super.close();
|
| + _stub.close();
|
| if (_application != null) {
|
| _application.close();
|
| }
|
| @@ -108,7 +114,7 @@ class PingPongApplication extends Application {
|
| PingPongApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle);
|
|
|
| void acceptConnection(String requestorUrl, ApplicationConnection connection) {
|
| - connection.provideService(PingPongService.name,
|
| + connection.provideService(PingPongServiceName,
|
| (endpoint) => new PingPongServiceImpl(this, endpoint));
|
| connection.listen();
|
| }
|
| @@ -117,6 +123,5 @@ class PingPongApplication extends Application {
|
| main(List args) {
|
| MojoHandle appHandle = new MojoHandle(args[0]);
|
| String url = args[1];
|
| - var pingPongApplication = new PingPongApplication.fromHandle(appHandle);
|
| - pingPongApplication.listen();
|
| + new PingPongApplication.fromHandle(appHandle);
|
| }
|
|
|