Closed irreal closed 4 years ago
Thanks a lot man, good job! Хвала брате!
Hey. Instead of broadcasting the response to all clients, how can I filter my response to a particular client out of all connected clients?
This thread is about my PR which adds better type support.
However, to give a short answer to your question: there is no broadcasting being done. The SSE method is an extension on the response object which is tied to a single specific client. You are supposed to analyze the request object (parse auth token, queru parameters, etc) then store the response object somewhere for later lookup. Then when you have a message for that specific client, you dig up the response object and use the sse method to send them the payload.
Hey, I made this adjustment so that when you install and use this package, you get full typing support on your Response parameter (all the usual Express things, plus the .sse from this package)
I don't have a lot of experience with typescript type definitions, but I tested it and it works just fine.