liamcottle/rustplus.js

Make it work for browser clients

Opened this issue · 3 comments

Would be nice to use it directly through a browser client instead of a Node backend

This is a nice idea. However, as far as I know, the nodejs and web browser websocket apis are different. So I'd need to find an existing wrapper, or write a custom one to be able to use the correct apis based on if the code is running in nodejs or in the browser.

Yeah I noticed that myself, after playing around with it. I got to the point where I could connect to the server, and someone decode the received messages. However I kept getting a "not found" message back, so I'm guessing I didn't encode it correctly.

Macil commented

After studying this project and using its .proto file, I previously made a webpage-based Stream Deck plugin that connects to the Rust+ API. It's not super clean code as the parts for connecting to the Rust+ API aren't separated at all from handling the Stream Deck API, but I figure it might be helpful to someone trying to use Rust+ in a webpage to study its code. code.js is where most of the code lives. The connection to the Rust+ API happens in the handleConnect function. You can look for uses of AppRequest and AppMessage to see how messages are sent and received for the Rust+ API. (code.html is where code.js and its dependency scripts are loaded from.)