Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WebAssembly support (GOARCH=wasm). #25

Open
silbinarywolf opened this issue Aug 28, 2018 · 3 comments
Open

Add WebAssembly support (GOARCH=wasm). #25

silbinarywolf opened this issue Aug 28, 2018 · 3 comments

Comments

@silbinarywolf
Copy link

silbinarywolf commented Aug 28, 2018

This package should be updated to use the following library so that websocket usage can target wasm and gopherjs:
"github.com/gopherjs/gopherwasm/js"

This will require wrapping callbacks with js.NewEventCallback() (and calling .Release()) and changing *js.Object to js.Value

@silbinarywolf
Copy link
Author

I have something functional but not elegant available for those interested here:
#26

I'm not really interested in covering this off properly as I will most likely move away from Websocket in the future.

@dmitshur dmitshur changed the title Does not work with Go 1.11 and WASM build Add WebAssembly support (GOARCH=wasm). Sep 10, 2018
@dmitshur
Copy link
Member

Thanks for opening the issue, and for sending a draft PR!

I tested it with one of my projects that uses WebSockets just now, and I can see that it compiles and functions partially, but after some amount of bytes (or messages), there is a discrepancy in the data sent/received, causing my protocol to report an error.

Still, it's helpful to have it as a reference, so thanks for providing it!

@nhooyr
Copy link
Contributor

nhooyr commented Sep 22, 2019

@dmitshur Instead of adding support for WASM to this package, what are your thoughts on recommending my WebSocket package instead? The client side can target WASM directly with nearly the same API as for non WASM targets

See coder/websocket#142

It should also work for GopherJS once GopherJS supports Go 1.13.

This would also resolve #29 and every other issue/PR on this library.

dmitshur pushed a commit that referenced this issue Nov 3, 2019
Add a link to nhooyr.io/websocket package with WebAssembly support.

Updates #25

GitHub-Pull-Request: #30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants