How to compile *only* the "raw websocket frame parser" (and writer) parts of fastwebsockets to WASM? of

⚓ rust    📅 2025-04-26    👤 surdeus    👁️ 1      

surdeus

I've been working on implementing a WebSocket server in a window of chrome browser in an Isolated Web App using WICG Direct Sockets TCPServerSocket.

Creating and managing the TCP socket from the browser is not the issue.

The JavaScript code I have cobbled together so far only works to echo messages up to 65336 length. Then things go wrong with the message output back to client.

fastwebsockets README says this

You can use it as a raw websocket frame parser and deal with spec compliance yourself,

so I'm thinking of trying to compile those parsing parts to WASM (and to JavaScript with Binaryen's wasm2js) to parse and write WebSocket frames, specifically parsing fragmented frames and continuation frames of messages of at least up to 10 MB.

Not being a Rustacean, I'm wondering is there a way to isolated just the FragmentCollector code, and compile that to WASM, where I pass JavaScript ArrayBuffer, or write to WebAssembly.Memory and get back the complete message read from memory or as a JavaScript ArrayBuffer?

1 post - 1 participant

Read full topic

🏷️ rust_feed