1
votes

If I have two different types of events then it seems there are two ways to separate the different types of the events using HTML5 Server Sent Events:

  1. Attaching the respective event keyword to every message pushed from the server.
  2. Exposing the different event types at different URLs.

As someone who has just started learning to use HTML5 SSE I wonder when would I use each method.

Any insights from the experienced users of this API?

P.S.

I do not think it matters, but my server side is Node+Express.

1

1 Answers

0
votes

If those two types of events are still in the same application then the best solution is to use single SSE connection and use different types of events within the stream.

This way you reduce number of open connections and overhead of establishing and keeping them alive.

If you had two independent applications on the same page (e.g. stock ticker and chat window) then having two separate streams might be easier just for sake of keeping codebases independent.