rust-websocket-lite
rust-websocket-lite copied to clipboard
Websocket server support
- ~
impl Encoder for UpgradeCodec
~ probably not, as the web framework will handle sending of headers for the Upgrade request - Integration with relevant web framework(s):
- [x] hyper
- [ ] rocket
- [ ] actix-web
Integration to include Autobahn conformance testing and example code.
I just realized this crate is currently aimed towards WebSocket clients more so than servers. Would it be relatively easy to have the encoder accept some sort of control on whether or not it masks messages? I'm building an MQTT server which works with WebSocket connections using this crate, and it's almost working aside from the server sending masked messages which the browser rejects.
I can help in writing it if you have a particular design you're after.
@1tgr I hacked together something just to see if I could get it working:
https://github.com/1tgr/rust-websocket-lite/compare/master...bschwind:master
Seems to function correctly! The change I made is technically a breaking one so I wouldn't recommend using it verbatim, but something along those lines would be helpful to be able to use this crate in a server setting. Thanks for writing it!
Thanks @bschwind, this is helpful. Do you have anything that integrates this library with a full web server? There is this example in hyper/examples/upgrade.rs, but it's not exactly at the point where it's plug-and-play.
@1tgr Unfortunately I don't, I'm using it for an MQTT-over-WebSockets broker so I only needed a subset of all WebSocket functionality. You can see its usage here:
https://github.com/bschwind/mqtt-broker/blob/dd5ff38985aa242ccd6e2e126a22b5ce312dcd46/mqtt-v5-broker/src/main.rs#L44-L60