pub enum TextMessage {
Publish {
name: String,
pubuid: u32,
data_type: String,
properties: Properties,
},
Unpublish {
pubuid: u32,
},
SetProperties {
name: String,
update: Properties,
},
Subscribe {
topics: Vec<String>,
subuid: u32,
options: SubscriptionOptions,
},
Unsubscribe {
subuid: u32,
},
Announce {
name: String,
id: u32,
data_type: String,
pubuid: Option<u32>,
properties: Properties,
},
Unannounce {
name: String,
id: u32,
},
Properties {
name: String,
ack: bool,
update: Properties,
},
}
Variants§
Publish
Sent from a client to the server to indicate the client wants to start publishing values at the given topic. The server shall respond with a Topic Announcement Message (TextMessage::Announce), even if the topic was previously announced. The client can start publishing data values via MessagePack messages immediately after sending this message, but the messages will be ignored by the server if the publisher data type does not match the topic data type.
Fields
pubuid: u32
A client-generated unique identifier for this publisher. Use the same UID later to unpublish. This is also the identifier that the client will use in MessagePack messages for this topic.
data_type: String
The requested data type (as a string).
If the topic is newly created (e.g. there are no other publishers) this sets the value type. If the topic was previously published, this is ignored. The TextMessage::Announce message contains the actual topic value type that the client shall use when publishing values.
Implementations should indicate an error if the user tries to publish an incompatible type to that already set for the topic.
properties: Properties
Initial topic properties.
If the topic is newly created (e.g. there are no other publishers) this sets the topic properties. If the topic was previously published, this is ignored. The TextMessage::Announce message contains the actual topic properties. Clients can use the TextMessage::SetProperties message to change properties after topic creation.
Unpublish
Sent from a client to the server to indicate the client wants to stop publishing values for the given topic and publisher. The client should stop publishing data value updates via binary MessagePack messages for this publisher prior to sending this message.
When there are no remaining publishers for a non-persistent topic, the server shall delete the topic and send a Topic Removed Message (TextMessage::Unannounce) to all clients who have been sent a previous Topic Announcement Message (TextMessage::Announce) for the topic.
Fields
pubuid: u32
The same unique identifier passed to the TextMessage::Publish message
SetProperties
Sent from a client to the server to change properties (see Properties) for a given topic. The server will send a corresponding Properties Update Message (TextMessage::Properties) to all subscribers to the topic (if the topic is published). This message shall be ignored by the server if the topic is not published.
Subscribe
Sent from a client to the server to indicate the client wants to subscribe to value changes for the specified topics / groups of topics. The server shall send MessagePack messages containing the current values for any existing cached topics upon receipt, and continue sending MessagePack messages for future value changes. If a topic does not yet exist, no message is sent until it is created (via a publish), at which point a Topic Announcement Message (TextMessage::Announce) will be sent and MessagePack messages will automatically follow as they are published.
Subscriptions may overlap; only one MessagePack message is sent per value change regardless of the number of subscriptions. Sending a subscribe message with the same subscription UID as a previous subscribe message results in updating the subscription (replacing the array of identifiers and updating any specified options).
Fields
topics: Vec<String>
One or more topic names or prefixes (if the prefix option is true) to start receiving messages for.
Unsubscribe
Sent from a client to the server to indicate the client wants to stop subscribing to messages for the given subscription.
Fields
subuid: u32
The same unique identifier passed to the TextMessage::Subscribe message
Announce
The server shall send this message for each of the following conditions:
- To all clients subscribed to a matching prefix when a topic is created
- To a client in response to an Publish Request Message (TextMessage::Publish) from that client
Fields
pubuid: Option<u32>
If this message was sent in response to a TextMessage::Publish message, the Publisher UID provided in that message. Otherwise absent.
properties: Properties
Topic Properties
Unannounce
The server shall send this message when a previously announced (via a Topic Announcement Message (TextMessage::Announce)) topic is deleted.
Properties
The server shall send this message when a previously announced (via a Topic Announcement Message (TextMessage::Announce)) topic has its properties changed (via Set Properties Message (TextMessage::SetProperties)).
Fields
ack: bool
True if this message is in response to a TextMessage::SetProperties message from the same client. Otherwise absent.
update: Properties
The client shall handle the update value as follows. If a property is not included in the update map, its value is not changed. If a property is provided in the update map with a value of null, the property is deleted.