summaryrefslogtreecommitdiffstats
path: root/mojo/apps/js/main.js
blob: 5f596c3d61ca0a461d9e9500d5e4e60c4103164f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2013 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.

define([
    "console",
    "mojo/apps/js/bindings/connector",
    "mojo/apps/js/bindings/threading",
    "mojom/hello_world_service",
], function(console, connector, threading, hello) {

  function HelloWorldClientImpl() {
  }

  HelloWorldClientImpl.prototype =
      Object.create(hello.HelloWorldClientStub.prototype);

  HelloWorldClientImpl.prototype.didReceiveGreeting = function(result) {
    console.log("DidReceiveGreeting from pipe: " + result);
    connection.close();
    threading.quit();
  };

  var connection = null;

  return function(handle) {
    connection = new connector.Connection(handle,
                                          HelloWorldClientImpl,
                                          hello.HelloWorldServiceProxy);

    connection.remote.greeting("hello, world!");
  };
});