ninjasource / embedded-websocket

A rust websocket library for embedded systems (no_std)
Apache License 2.0
98 stars 28 forks source link

Return sub_protocol on server accept #10

Open nworbnhoj opened 2 years ago

nworbnhoj commented 2 years ago

It seem odd that this call to server_accept forces websocket_protocol to None.

The change proposes a slightly less blunt approach of defaulting to WebSocketContext.sec_websocket_protocol_list[0]

This probably should also include doco for the Server implmentation.

ninjasource commented 2 years ago

I like the idea of supporting sub protocols in the framer module but I don't think your implementation would work for all use cases.

I would be better to pass in the chosen websocket sub protocol as follows:

sec_websocket_key: &WebSocketKey,
sec_websocket_protocol: Option<&WebSocketSubProtocol>,