Closed FilterUnfiltered closed 2 years ago
I am aware that the method for which the client subs/unsubs is not the most elegant, but I figured using JSON is the simplest for most uses.
Thanks for the work on this. However I feel the publish/subscribe can easily be implemented by the user using the library and I can't see a good reason to add such higher-level functionality in a generic library which this is aimed to be.
Feel free to comment any thoughts, but keep in mind I would need very good reasoning for adding high-level functionality (mainly due to maintenance burden).
I have been using this for a while now but realized I see no way to separate clients so I can send specific info to some of them and not to others, without doing so manually. So I added the ability for clients to "subscribe" to a specific service by sending this to the server:
{"subscribe": "service_name"}
and unsubscribe by using{"unsubscribe": "service_name"}
. The server can then send info to only those subscribed to the service by usingserver.publish("service_name", "you guys are the VIPs")
This also adds event functions for every time a client subscribes or unsubscribes, as well as an easy-to-access object containing all the services and their subscribers.
This is my first time contributing to an open-source project so I am sorry for anything dumb I might have done.