liamcottle / rustplus.js

Unofficial NodeJS library for controlling Smart Switches in the PC game Rust
224 stars 46 forks source link

Make it work for browser clients #23

Open RasmusGodske opened 3 years ago

RasmusGodske commented 3 years ago

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

liamcottle commented 3 years ago

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.

RasmusGodske commented 3 years ago

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 11 months ago

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.)