Send webpage config in multiple parts
Change-Id: I87b90ea5ec498e93647bb04012a51f687c05a4a0
diff --git a/aos/network/www/proxy.ts b/aos/network/www/proxy.ts
index 7bcf575..7491ad5 100644
--- a/aos/network/www/proxy.ts
+++ b/aos/network/www/proxy.ts
@@ -90,8 +90,8 @@
// Handle messages on the DataChannel. Handles the Configuration message as
// all other messages are sent on specific DataChannels.
- onDataChannelMessage(e: MessageEvent): void {
- const fbBuffer = new flatbuffers.ByteBuffer(new Uint8Array(e.data));
+ onConfigMessage(data: Uint8Array): void {
+ const fbBuffer = new flatbuffers.ByteBuffer(data);
this.configInternal = Configuration.getRootAsConfiguration(fbBuffer);
for (const handler of Array.from(this.configHandlers)) {
handler(this.configInternal);
@@ -146,8 +146,8 @@
this.rtcPeerConnection.addEventListener(
'datachannel', (e) => this.onDataChannel(e));
this.dataChannel = this.rtcPeerConnection.createDataChannel('signalling');
- this.dataChannel.addEventListener(
- 'message', (e) => this.onDataChannelMessage(e));
+ this.handlers.add(
+ new Handler((data) => this.onConfigMessage(data), this.dataChannel));
window.dc = this.dataChannel;
this.rtcPeerConnection.addEventListener(
'icecandidate', (e) => this.onIceCandidate(e));