blob: 9b37d70e40bb728af499aa33765a5f777ea146a2 [file] [log] [blame]
Alex Perry5f474f22020-02-01 12:14:24 -08001import {aos} from 'aos/events/ping_generated';
2
3export function HandlePing(data: Uint8Array) {
4 const fbBuffer = new flatbuffers.ByteBuffer(data);
5 const ping = aos.examples.Ping.getRootAsPing(fbBuffer);
6
7 document.getElementById('val').innerHTML = ping.value();
8 document.getElementById('time').innerHTML = ping.sendTime().low;
9}
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}