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

Impossible to set subprotocol #1

Closed
mephinet opened this issue Oct 23, 2015 · 7 comments
Closed

Impossible to set subprotocol #1

mephinet opened this issue Oct 23, 2015 · 7 comments

Comments

@mephinet
Copy link

I'm rather new to async websocket programming, so I might miss the obvious - but I wasn't able to find a way to set the Sec-WebSocket-Protocol of the Response sent by AnyEvent::WebSocket::Server.
The establish* methods of the Server implementation use Protocol::WebSocket::Handshake::Server to create the HTTP 101 response for the received request. However, they do not allow for the application to influence the creation of the Protocol::WebSocket::Response - so the user cannot set the "subprotocol" field.

@debug-ito
Copy link
Owner

It's not related to async operation, so you are right. Currently we have no way to fine-tune the response. Unfortunately, Protocol::WebSocket module family does not expose so many public (and well-documented) methods, so there are few things we can do.

If you really want this feature (i.e., setting sub-protocol in the response), I can make a necessary pull-request to vti/protocol-websocket. After the new version of Protocol::WebSocket is released, I can implement the feature.

@debug-ito
Copy link
Owner

Oops. I found Protocol::WebSocket::Handshake has res method and it's documented.

OK, I'll try using this to make an interface to customize the request..

@mephinet
Copy link
Author

That would be great! 👍

@debug-ito
Copy link
Owner

Released version 0.06.

@mephinet
Copy link
Author

Thanks a lot, I'll give it a try!

@mephinet
Copy link
Author

Perfect, specifying a handshake callback allows me to call subprotocol on the response object! Thanks again.

@debug-ito
Copy link
Owner

I'm glad to hear that. Thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants