Channel Status API
Having access to channel metadata can provide numerous benefits. In a scenario where the number of subscribers of a channel goes well beyond a hundred, usage of other options such as presence becomes less effective leading to an unexpected n-squared problem if all of the clients are subscribed to presence. You could instead make use of our channel metadata to check the number of active subscribers.
Equally, you may want to publish your data only if there is a subscriber for that data. The channel lifecycle events can notify you when a channel is opened, becomes active, or is no longer active thus giving your publisher clients an opportunity to know when the last subscriber leaves the channel.
Channel Status API Reference
The payload of lifecycle events for channels is the ChannelDetails type which contains the
channelId and other static information about the channel, plus a
status containing a ChannelStatus instance which contains information about the current state of the channel.
ChannelDetails is an object returned when requesting channel metadata. It contains information on the channel itself, along with the current state of the channel in the ChannelStatus object.
- the required name of the channel including any qualifier, if any
- in events relating to the activity of a channel in a specific region, this optionally identifies the region
- in events relating to the activity of a channel in a specific region, this optionally identifies whether or not that region is resonsible for global coordination of the channel
- an optional ChannelStatus instance
ChannelStatus is contained within the above ChannelDetails object, and optionally contains the below Occupancy object.
- a required boolean value indicating whether the channel that is the subject of the event is active. For events indicating regional activity of a channel this indicates activity in that region, not global activity
- an optional Occupancy instance indicating the occupancy of the channel. For events indicating regional activity of a channel this indicates activity in that region, not global activity.
Occupancy is optionally contained within the above ChannelStatus object, and contains information on the occupants of the channel. This is usually contained within the metrics object, an optional dictionary of membership categories for a realtime channel and their counts. Membership categories include:
- the number of connections attached to the channel that are authorised to publish
- the number of connections attached that are authorised to subscribe to messages
- the number of connections that are authorised to subscribe to presence messages
- the number of connections that are authorised to enter members into the presence channel
- the number of members currently entered into the presence channel