// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:mojo_application';
import 'dart:mojo_bindings';
import 'dart:mojo_core';

import 'package:mojo/services/console/public/interfaces/console.mojom.dart';

class ConsoleApplication extends Application {
  ConsoleProxy _proxy;

  ConsoleApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle);

  void initialize(List<String> args) {
    _proxy = new ConsoleProxy.unbound();
    connectToService("mojo:console", _proxy);

    _proxy.readLine().then((result) {
        _proxy.printLines([result.line]).then((result) {
            _proxy.close();
            close();
          });
      });
  }
}

main(List args) {
  var appHandle = new MojoHandle(args[0]);
  var consoleApplication = new ConsoleApplication.fromHandle(appHandle);
  consoleApplication.listen();
}

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';
import 'dart:mojo_application';
import 'dart:mojo_bindings';
import 'dart:mojo_core';

import 'package:mojo/services/console/public/interfaces/console.mojom.dart';

class ConsoleApplication extends Application {
  ConsoleProxy _proxy;

  ConsoleApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle);

  void initialize(List<String> args) {
    _proxy = new ConsoleProxy.unbound();
    connectToService("mojo:console", _proxy);
    run();
  }

  run() async {
    var result = await _proxy.readLine();
    await _proxy.printLines([result.line]);

    _proxy.close();
    close();
  }
}

main(List args) {
  var appHandle = new MojoHandle(args[0]);
  var consoleApplication = new ConsoleApplication.fromHandle(appHandle);
  consoleApplication.listen();
}

Use await syntax in the console example.
Use await syntax in the console example.

BUG=none
R=zra@google.com

Review URL: https://codereview.chromium.org/896873003
