rexxars / sse-channel

Server-Sent Events "channel" where all messages are broadcasted to all connected clients, history is maintained automatically and server attempts to keep clients alive by sending "keep-alive" packets automatically.
MIT License
111 stars 11 forks source link

method channel.send(msg, [clients]) #20

Open gaxolio opened 6 years ago

gaxolio commented 6 years ago

Hi. This is not a issue but I need to send a message only to a client. Could you describe better how use this method? What do you mean with [clients]? Could you provide an example. Is it an array of what? How can I match my client in the list of clients. Thanks for support. Sergio

gaxolio commented 5 years ago

Hi. Please, could you provide an example for the method channel.send(msg, [clients]) with the optional parameter [clients]? Thank you.

cuxs commented 5 years ago

Any news on this?

janober commented 5 years ago

Just needed the same. The documentation does not explain what to use but in the source-code it does. You simply have to give it the response objects of the clients you want to send the data to. So simply keep it around from the time when they connect and then supply it there when you want to send them data. Hope it helps.

You can find the information here in the source code: https://github.com/rexxars/sse-channel/blob/master/lib/sse-channel.js#L195