WebSockets & Real-Time Communication

How should large binary data be handled in WebSocket communications?
const ws = new WebSocket('ws://example.com');

// Sending binary data
ws.binaryType = 'arraybuffer';
const buffer = new ArrayBuffer(1024);
// ... fill buffer with data
ws.send(buffer);

// Receiving binary data
ws.onmessage = (event) => {
    if (event.data instanceof ArrayBuffer) {
        const view = new DataView(event.data);
        // Process binary data
    }
};
Next Question (8/17)