Handle subscription of messages in the webapp.
Messages larger than a threshold are split and reassembled due to the
size limit in webrtc. Threshold may have to be adjusted somewhere between
64KiB and 256KiB.
This also includes a basic handler for a ping message and a more
advanced image handler.
Change-Id: If66acfb1bb84e9d3ff686994a94b1480cb70b2aa
diff --git a/aos/network/www/ping_handler.ts b/aos/network/www/ping_handler.ts
new file mode 100644
index 0000000..9b37d70
--- /dev/null
+++ b/aos/network/www/ping_handler.ts
@@ -0,0 +1,26 @@
+import {aos} from 'aos/events/ping_generated';
+
+export function HandlePing(data: Uint8Array) {
+ const fbBuffer = new flatbuffers.ByteBuffer(data);
+ const ping = aos.examples.Ping.getRootAsPing(fbBuffer);
+
+ document.getElementById('val').innerHTML = ping.value();
+ document.getElementById('time').innerHTML = ping.sendTime().low;
+}
+
+export function SetupDom() {
+ const ping_div = document.createElement('div');
+ document.body.appendChild(ping_div);
+
+ const value_div = document.createElement('div');
+ value_div.setAttribute('id', 'val');
+ const time_div = document.createElement('div');
+ time_div.setAttribute('id', 'time');
+
+ ping_div.appendChild(value_div);
+ ping_div.appendChild(time_div);
+}
+
+export function GetId() {
+ return aos.examples.Ping.getFullyQualifiedName();
+}