You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem and I don't exactly know how to solve it. Currently, I'm using this library to subscribe clients to specific events. However, in my case, a client can subscribe to multiple events. So, I have to open an EventSource per event source.
My question is, could it be possible to have only one EventSource and in my node server have a route like events/:eventID/subscribe
which, assuming the client has already opened an EventSource and a SseChannel for the eventID exists, add the client to the SseChannel so the next message sent to the channel is received by the client?
The response content type of this url should be application/json just saying something like "Ok, you'll receive updates in your EventSource" and may be, trigger a message in the EventSource.
How would you solve this or attack this problem? I'm a clueless here.
The text was updated successfully, but these errors were encountered:
I ran into this as well and I ended up solving it by constructing my own logical channels rather than utilizing the literal channels included in sse-channel. Each message that gets sent out includes a channels array and the client is responsible for handling channel-targeted messages accordingly (the client knows what channels it cares about). This worked in my environment because I wrote both the API and the client code, and the data is not sensitive (all clients receive every message and that's OK). Whether or not this approach would work for you depends on the details of your specific use case, of course.
How about having a SseChannel per event and use query params which would have array of events cilents want to subscribe to. Then in the handler of that route you could add that client to all the channels listed in that query param.
Hi
I have a problem and I don't exactly know how to solve it. Currently, I'm using this library to subscribe clients to specific events. However, in my case, a client can subscribe to multiple events. So, I have to open an
EventSource
per event source.My question is, could it be possible to have only one
EventSource
and in my node server have a route likeevents/:eventID/subscribe
which, assuming the client has already opened an
EventSource
and aSseChannel
for theeventID
exists, add the client to theSseChannel
so the next message sent to the channel is received by the client?The response content type of this
url
should beapplication/json
just saying something like "Ok, you'll receive updates in your EventSource" and may be, trigger a message in theEventSource
.How would you solve this or attack this problem? I'm a clueless here.
The text was updated successfully, but these errors were encountered: