2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-05-13 13:22:29 -07:00
|
|
|
import {ApplicationRef} from '@angular/core';
|
2016-06-10 10:21:53 -07:00
|
|
|
import {UiArguments, FnArg, PRIMITIVE, ClientMessageBrokerFactory} from '@angular/platform-browser';
|
2016-06-15 08:25:31 -07:00
|
|
|
import {bootstrapWorkerUi} from "@angular/platform-browser-dynamic";
|
2015-09-01 10:55:11 -07:00
|
|
|
|
2016-04-12 09:40:37 -07:00
|
|
|
const ECHO_CHANNEL = "ECHO";
|
2015-09-01 10:55:11 -07:00
|
|
|
|
2016-05-13 13:22:29 -07:00
|
|
|
export function main() {
|
2016-06-15 08:25:31 -07:00
|
|
|
bootstrapWorkerUi("loader.js").then((ref) => afterBootstrap(ref));
|
2016-05-13 13:22:29 -07:00
|
|
|
}
|
2015-09-01 10:55:11 -07:00
|
|
|
|
2016-04-14 14:52:35 -07:00
|
|
|
function afterBootstrap(ref: ApplicationRef) {
|
|
|
|
let brokerFactory: ClientMessageBrokerFactory = ref.injector.get(ClientMessageBrokerFactory);
|
|
|
|
var broker = brokerFactory.createMessageBroker(ECHO_CHANNEL, false);
|
2015-09-01 10:55:11 -07:00
|
|
|
|
2016-04-14 14:52:35 -07:00
|
|
|
document.getElementById("send_echo")
|
|
|
|
.addEventListener("click", (e) => {
|
|
|
|
var val = (<HTMLInputElement>document.getElementById("echo_input")).value;
|
|
|
|
// TODO(jteplitz602): Replace default constructors with real constructors
|
|
|
|
// once they're in the .d.ts file (#3926)
|
|
|
|
var args = new UiArguments("echo");
|
|
|
|
args.method = "echo";
|
|
|
|
var fnArg = new FnArg(val, PRIMITIVE);
|
|
|
|
fnArg.value = val;
|
|
|
|
fnArg.type = PRIMITIVE;
|
|
|
|
args.args = [fnArg];
|
|
|
|
|
|
|
|
broker.runOnService(args, PRIMITIVE)
|
|
|
|
.then((echo_result: string) => {
|
|
|
|
document.getElementById("echo_result").innerHTML =
|
|
|
|
`<span class='response'>${echo_result}</span>`;
|
|
|
|
});
|
|
|
|
});
|
2016-04-28 17:50:03 -07:00
|
|
|
}
|