Skip to main content

Publish / Subscribe

Each realm in Hivekit comes with a convenient publish/subscribe mechanism that enables fast and straightforward many-to-many messaging. This mechanism is ideal for transmitting data that isn't directly associated with the state of objects, areas, or instructions, such as event notifications, incoming messages, alerts, and more.

Internally, Hivekit uses the same publish/subscribe mechanism to broadcast server-side events, like connectionStatusChanged, when a new data provider becomes available.

Every connected client and backend process can send and receive messages through this mechanism. If needed, you can use ID patterns to set permissions for clients to publish or receive specific messages.

Publish/Subscribe is a great tool if you wish to:

  • Send alerts or notifications to apps or endpoints.
  • Remotely trigger actions or issue commands
  • Have simple, ephemeral messaging between connected clients.

Using ID Patterns for Enhanced Control

ID patterns come in handy when you need precise control over message routing and permissions, particularly when multiple subscribers must respond to subsets of events. For example, if you have separate backend processes handling maintenance for bikes and scooters, ID patterns can easily route events to the correct receiver, ensuring that events are processed by the appropriate system.

In summary, Hivekit's publish/subscribe mechanism enables efficient many-to-many messaging, ensuring seamless communication across clients and backend processes. Using ID patterns further enhances control over message routing and permissions, allowing for a more organized and effective system.