CloudEvent
Since 6.3.0:
The CloudEvent
class is available in Device OS 6.3.0 and later and is the recommended way to handle
publish and subscribe. It is both a container for the event name, event data, and content type, but also maintains the process in
publishing and any error that occurs while publishing.
You typically store a CloudEvent
object as a global variable or class member variable. You should not allocate a
CloudEvent
as a non-static local variable within a function because it not only holds the data, but it is also
used to convey whether the publish succeeded or not. The Particle.publish()
overload that takes a CloudEvent
is asynchronous
and returns before the publish has completed. The CloudEvent
must remain allocated until the publish is actually complete,
by success or failure.
For more information and examples, see the typed and extended publish page.