CloudEvent
Getting and settings - CloudEvent
name - CloudEvent
Sets the event name. The name is copied by the setter.
// PROTOTYPE - setter
CloudEvent& name(const char* name)
// PROTOTYPE - getter
const char* name() const;
contentType - CloudEvent
Set or get the content type for the event.
// PROTOTYPE - setter
CloudEvent& contentType(ContentType type)
// PROTOTYPE - getter
ContentType contentType() const
Content Type Constant | MIME Type | Value |
---|---|---|
ContentType::TEXT |
text/plain; charset=utf-8 |
0 |
ContentType::JPEG |
image/jpeg |
22 |
ContentType::PNG |
image/png |
23 |
ContentType::BINARY |
application/octet-stream |
42 |
ContentType::STRUCTURED |
65001 |
When publishing you typically set the value, but you can also get the value that was previously set.
When subscribing to an event, you typically get the value to see what the publisher of the event has set.
You don't typically set the content type to STRUCTURED
; when you set the data from a Variant
this is handled automatically for you.
data - from c-string - CloudEvent
Copies data from a c-string (null terminated string) into the event data.
Typically used with the TEXT
content type. The data cannot contain a null byte at a location other than the
end of a string so this is not suitable for binary data.
// PROTOTYPE
CloudEvent& data(const char* data)
data - from pointer and length - CloudEvent
Copies data from a buffer specified with pointer and length. This is useful if the data source is not null-terminated.
This can be used with binary data, though you will typically use the overload that also includes the ContentType instead.
// PROTOTYPE
CloudEvent& data(const char* data, size_t size);
data - from pointer and length with content type - CloudEvent
Copies data from a buffer specified with pointer and length. This is typically used with binary data.
See Content-Type, above, for the valid values.
// PROTOTYPE
CloudEvent& data(const char* data, size_t size, ContentType type)
data - from String - CloudEvent
Copies data from a String
object.
// PROTOTYPE
CloudEvent& data(const String& data)
dataString - CloudEvent
Returns a copy of the data as a String
. This is typically used for text data.
// PROTOTYPE
String dataString() const
data from Buffer - CloudEvent
Copies binary data from a Buffer
object. This is an alternative to using a pointer and length.
// PROTOTYPE
CloudEvent& data(const Buffer& data)
data - to Buffer - CloudEvent
Returns a copy of the data in the CloudEvent
as a Buffer
object. This is typically used for binary data.
// PROTOTYPE
Buffer data() const
data - from EventData - CloudEvent
Copies data from an EventData
object, which is a Variant
. This is used for structured data.
// PROTOTYPE
CloudEvent& data(const EventData& data)
data - to EventData - CloudEvent
Returns a copy of the structured data in the CloudEvent
as an EventData
object, which is a Variant
.
// PROTOTYPE
EventData dataStructured() const
For more information, see structured subscription in the typed and extended publish page.