Events not working for my core

I am using PIR Motion sensor and trying to publishing an event “move” whenever it detects the motion.

Spark.publish(“move”, “Motion Detected”);

Now, I am using the sparkJS and trying to catch the event through this code:

var spark = require('spark');

//Get test event for specific core
spark.getEventStream('move', 'MyCoreid', function(data) {
  console.log("Event: " + data);
});


});


// Login as usual
spark.login({accessToken: 'MyAccessToken'});

but when I run it says event : ok and after that it is getting stuck.

What I am doing wrong here? Please help !

Hi @satendra4u

Are you sure the event is being published from the core? Maybe you should check with curl first? I have been looking at the public event stream for a few minutes and have not seen any “move” events.

Hi bko,

The event is getting published only when there is motion. I have starting moving and I hope you would have seen some “move” events.

I tired with curl

curl -H "Authorization: Bearer Access token " https://api.spark.io/v1/events/move

it says event ok:

and after that whenever I do some motions , the cursor comes down without writing the text “Motion Detected”.

Please see below:

Thanks,
Satyen

HI @satendra4u

I don’t think your core is publishing. I left my monitor running and saw zero “move” events. Note that the spelling must exactly match.

What you are seeing with curl and SparkJS are the keep-alives that the cloud sends every 9 seconds to keep the event listener open. When you do get an event, you get a JSON from the cloud that you can’t miss.

Thanks for your help. Let me check this.

hi bko,

Do we have SSE for spark in ios?? I am using SSE in JS as of now but my requirement is to make a ios app and I wanted to use the ios code for SSE rather this JS.

Please let me know if we have any.

Thanks,
Satyen

I have not tried it but I think you will find this interesting:

Thanks bko. I am checking it now.