blob: a7fb0d4db1d165c0175173b83d6e69b5f26a61cc [file] [log] [blame]
Austin Schuh7c75e582020-11-14 16:41:18 -08001import {aos} from 'aos/events/ping_generated';
Alex Perry5f474f22020-02-01 12:14:24 -08002
3export function HandlePing(data: Uint8Array) {
4 const fbBuffer = new flatbuffers.ByteBuffer(data);
Austin Schuh7c75e582020-11-14 16:41:18 -08005 const ping = aos.examples.Ping.getRootAsPing(fbBuffer);
Alex Perry5f474f22020-02-01 12:14:24 -08006
Philipp Schrader47445a02020-11-14 17:31:04 -08007 document.getElementById('val').innerHTML = ping.value().toString();
8 document.getElementById('time').innerHTML = ping.sendTime().low.toString();
Alex Perry5f474f22020-02-01 12:14:24 -08009}
10
11export function SetupDom() {
12 const ping_div = document.createElement('div');
13 document.body.appendChild(ping_div);
14
15 const value_div = document.createElement('div');
16 value_div.setAttribute('id', 'val');
17 const time_div = document.createElement('div');
18 time_div.setAttribute('id', 'time');
19
20 ping_div.appendChild(value_div);
21 ping_div.appendChild(time_div);
22}
23
24export function GetId() {
25 return aos.examples.Ping.getFullyQualifiedName();
26}