Would it be possible to introduce labels to the Socket object so that we can then get a list of only those sockets that have a certain label?
This is not like a Room because any Socket can possibly have multiple labels.
Then a label filter could be used in the broadcast method in order to broadcast to the subset of users with a certain label.
For example:
var sockets = Streamy.sockets({label: "puppy"}) // returns all connected socket objects with label "puppy".
Streamy.broadcastLabel('puppy', 'some_message', { data: 'world!' }); // broadcasts data to all connected socket objects with label "puppy".
Currently I am trying to simply add a label to a Socket object and then parse the list of sockets to only emit to the ones that have a given label, but I fear with a lot of users sending messages, the constant for loop parsing of all the socket objects will slow things down :(
Would it be possible to introduce labels to the Socket object so that we can then get a list of only those sockets that have a certain label?
This is not like a Room because any Socket can possibly have multiple labels.
Then a label filter could be used in the broadcast method in order to broadcast to the subset of users with a certain label.
For example: var sockets = Streamy.sockets({label: "puppy"}) // returns all connected socket objects with label "puppy".
Streamy.broadcastLabel('puppy', 'some_message', { data: 'world!' }); // broadcasts data to all connected socket objects with label "puppy".
Currently I am trying to simply add a label to a Socket object and then parse the list of sockets to only emit to the ones that have a given label, but I fear with a lot of users sending messages, the constant for loop parsing of all the socket objects will slow things down :(