I was not able to get the onmessage handler to fire on SSE’s either. After trying out a bunch of stuff, I think that this is because the event.type is ‘message’ for that handler and not any of our event types. When I run web-based examples of the onmessage handler, the event.type is always message, which leads me to think that this is browser thing and not an SSE thing.
I do not know how to build a listener for an entire stream, not just one named event type. I strongly suspect that this may be possible, but I have not figured it out either. A work-around would be to publish all your events under one type (such as ‘message’) and then use (say) a JSON as the data with your own private event type field in the data.
I don’t really see this as a big limitation, however. Since you know the names of every event that your core firmware is publishing, you could also just write a handler for each one.
That experiment clarifies what’s happening. That’s for trying that out. I hadn’t thought of that.
Unfortunately I still don’t have a solution.
I’m building an event viewer for my spark tools service to help the community here.
The goal is to show a live stream of events given only a device id to ease development and troubleshooting. This means I actually don’t know the event names. Not my cores.
If you just do a get request from a browser (view source chrome) for deviceid/events I can see all events just fine.
This tells me the server is doing it’s job just fine and this is an event source feature limitation.