Skip to content

WebSocket: Allow setting a protocol #1509

@chrysn

Description

@chrysn

Describe the feature you'd like

The WebSocket browser API can indicate a particular protocol (basically a sub-protocol of WebSockets) when creating a socket. This is currently not exposed in the WebSocketService API, but should be.

Is your feature request related to a problem?

For implementing CoAP over WebSockets (RFC8323), setting this is mandatory. (Everything else there works fine, and I'm currently working around it by using a server that's not as strict as the spec).

Describe alternatives you've considered

Other than having the client reimplement most of the WebSocketService module (how much depends on which private types would be needed), I see none.

Additional context

This looks pretty straight-forward. I've only looked at the web_sys side of things so far, but there it's a matter of calling into new_with_str_sequence rather than new. On the yew API side it'd be a bit messier due to combinatorial explosion ({,_binary,_text}{,_with_protocol}). The way around would be a builder-style interface, but that's even a larger API change, so probably it'll just be adding _with_protocol versions for now.

Questionnaire

  • I'm interested in implementing this myself but don't know where to start
  • I would like to add this feature
  • I don't have time to add this right now, but maybe later

More precisely: I'll give it a try, but please stop me here if this is already WIP, there's a larger plan for the API or there are any particular urgent considerations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions