[Libwebsockets] dynamic websocket_protocols

Michael Haberler mail17 at mah.priv.at
Wed Sep 18 10:27:01 CEST 2013


Hi Andy, good to see you back! 

Question - not sure this can be done in the current framework:

I use libwebsockets to serve messages to/from zeroMQ, among them publish/subsubscribe patterns

as for mapping channels to sockets, the easiest way is to map a ZMQ_PUB channel identity (a string) to a websocket protocol of the same identity - a client subscribing to a particular channel would select a matching protocol name

this works fine in a static setup; however the set of channels in my project may vary over time; in my current scheme that would suggest a varying libwebsocket_protocols array, and fiddling with that array at runtime while connections are open doesnt strike me as a good idea

any suggestions how to do that?

the other alternative I see is in-band signaling while the connection is open (a single protocol in that case) - have the server offer a list of channels by say a json object, and have the client send a subscribe JSON object in reply which will cause the server instance to subscribe to the channels listed in that message

I'm not a great friend of in-band signaling if it can be avoided.. I might be missing something, however maybe there is a different way to fudge the channel list/subscription message through HTTP headers? (I am too HTTP agnostic to know)

thanks in advance!


best regards

Michael

ps: I am very eager to see Andrew Canaday's libev work to fold back into mainline - I think it's the way to go as far as event loops go





More information about the Libwebsockets mailing list