api - what are the difference between particle.publish event and particle.subscribe event in particle.cloud? -


what particle.publish , particle.subscribe event in particle.cloud api .i sort of confused on application while building android application internet of thing product.

particle.publish() 

publish event through particle cloud forwarded registered callbacks, subscribed streams of server-sent events, , other devices listening via particle.subscribe().this feature allows device generate event based on condition. example, connect motion sensor device , have device generate event whenever motion detected.

particle.subscribe() 

subscribe events published devices.this allows devices talk each other easily. example, 1 device publish events when motion sensor triggered , subscribe these events , respond sounding alarm.

to use particle.subscribe(), define handler function , register in setup().

references:

https://docs.particle.io/reference/firmware/photon/#cloud-functions


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -