Re: [webrtc-pc] WHATWG streams for data channel messages (#1732)

Async iteration has landed to the stream specs:

So it could be possible to write the following code:
const dc = pc.createDataChannel(...);
dc.binaryType = 'stream';
// We only need one small buffer per channel
const buffer = new Uint8Array(myPreferredChunkSize);
let view = new DataView(buffer.buffer, 0);

// Note: The function is declared async!
dc.onmessage = async (event) => {
    for await (const chunk of {
       view = chunk.value; // We reclaim the buffer here
            // ... write the view's data to disk

GitHub Notification of comment by murillo128
Please view or discuss this issue at using your GitHub account

Received on Wednesday, 6 February 2019 09:09:50 UTC