lemunozm / message-io

Fast and easy-to-use event-driven network library.
Apache License 2.0
1.12k stars 75 forks source link

Feature Request: Accept WebSocket URLs with parameters. #168

Closed hschneider closed 9 months ago

hschneider commented 9 months ago

At first thanks for this awesome crate :-)

As far as I can see, a WS url has this format:

ws://ip_address:port

But some servers require more complex urls like

ws://ip_address:port?parameter=value&parameter2=value ...

This is often used to submit auth tokens etc. Would be great to have this feature, too.

Thank you very much, Harald

hschneider commented 9 months ago

Just wanted to add that there are also websocket URLs like

ws://subdomain.domain.tld/api/v1:8080?param1=value1&param2=value2 ....

So subdomain and URL paths should be supported too.

-- Harald

lemunozm commented 9 months ago

Hi @hschneider I'm glad you like message-io 😃

I think the feature you request is already done specifying the connection as RemoteAddr::Str(url), where you can specify the URL you want. Have you tried that?

hschneider commented 9 months ago

You're the best :-)

let (server, _) = handler.network().connect(Transport::Ws, RemoteAddr::Str("ws://127.0.0.1:8080?test=1".to_string())).unwrap();

did the trick. Perfect!