You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for giving me something to think about. I'm not convinced the following is a good idea, but it's currently unclear to me on how we could go about this in a better way.
The client API is all I personally need, so that'd be what I'd want to target initially and I haven't given it any thought really. I suppose it would need to fail on browsers but work for NodeJS?
I'm thinking SetPingHandler and SetPongHandler would become no-ops (assuming you only use for setting read deadlines)
Panic on header arguments that are impossible in the browser. If you're maintaining your code to work with both Web/Native, then you won't utilize arguments that aren't supported.
Build tags to switch between wasm and non-wasm code.
I recently helped add WebAssembly support to pion/webrtc and have an open PR to do the same for goleveldb. I would be interested in building WebAssembly support for this package to and we would use it in libp2p/go-ws-transport and 0xProject/0x-mesh (my project at work).
Is this still something you're interested in and would you accept a PR?
After looking more at the API for gorilla/websocket, I think adding WebAssembly support is harder than I first imagined. The API surface area is large and too much of it would not translate well to the native JavaScript API (this is in contrast to pion/webrtc which closely mimics the JavaScript API and goleveldb where only a small portion of the code related to storage needed to be changed at all). For now, it was much easier for me to add WebAssembly support in the higher-level libp2p/go-ws-transport package. I can still help offer advice or review a PR if someone else wants to take this on.
Activity
silbinarywolf commentedon Sep 29, 2018
Thanks for giving me something to think about. I'm not convinced the following is a good idea, but it's currently unclear to me on how we could go about this in a better way.
SetPingHandlerandSetPongHandlerwould become no-ops (assuming you only use for setting read deadlines)albrow commentedon Aug 5, 2019
I recently helped add WebAssembly support to pion/webrtc and have an open PR to do the same for goleveldb. I would be interested in building WebAssembly support for this package to and we would use it in libp2p/go-ws-transport and 0xProject/0x-mesh (my project at work).
Is this still something you're interested in and would you accept a PR?
albrow commentedon Aug 27, 2019
After looking more at the API for
gorilla/websocket, I think adding WebAssembly support is harder than I first imagined. The API surface area is large and too much of it would not translate well to the native JavaScript API (this is in contrast to pion/webrtc which closely mimics the JavaScript API and goleveldb where only a small portion of the code related to storage needed to be changed at all). For now, it was much easier for me to add WebAssembly support in the higher-level libp2p/go-ws-transport package. I can still help offer advice or review a PR if someone else wants to take this on.nhooyr commentedon Sep 24, 2019
For anyone who needs this feature now, I've implemented it v1.6.3 of my WebSocket library with @albrow's review.
See https://godoc.org/nhooyr.io/websocket#hdr-Wasm