[Solved] Spark Publish, NodeJS and EventSource

Hi @hansamann

I think your problem is a name mismatch. The listener you add must match the event name and from the URL you are using, the event name is “myevent” by the listener is listening for “Environment”. You need to either remove myevent and listen for all events from that device or make them the same. I would drop “myevent” from the URL and just listen for the event name you are publishing from your core.

In any case, these names need to match what are you using in Spark.publish("Environment",...) or "myevent" as you want.

For @emc2: The onmessage function listens for an event named “message” which is the default event that browsers use. If you make your core do Spark.publish("message", ...) then you can use that, but there is no need to do so.

See here for the Javascript version:

1 Like