2016-04-28 17:50:03 -07:00
|
|
|
import {Provider, ApplicationRef} from '@angular/core';
|
2016-04-12 09:40:37 -07:00
|
|
|
import {
|
2016-04-14 14:52:35 -07:00
|
|
|
bootstrapRender,
|
2016-04-12 09:40:37 -07:00
|
|
|
UiArguments,
|
|
|
|
FnArg,
|
|
|
|
PRIMITIVE,
|
|
|
|
ClientMessageBrokerFactory
|
2016-04-28 17:50:03 -07:00
|
|
|
} from '../../../../@angular/platform-browser/src/worker_render';
|
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-04-14 14:52:35 -07:00
|
|
|
bootstrapRender("loader.js").then((ref) => afterBootstrap(ref));
|
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
|
|
|
}
|