Announcement channels:
Elvis has left the building!

  • Jan 02, 2018
  • Starting Guide

With Realtime Messaging the announcement channels are used to announce client events such as a client connection and disconnection, among others.

These announcement channels are the following: ortcClientConnected, ortcClientDisconnected, ortcClientSubscribed and ortcClientUnsubscribed. These channels behave like regular pub/sub channels in terms of subscriptions, the only difference is that only the Realtime Messaging Servers can publish messages using them.

As an example we can say that whenever a client connects a message is published at the ortcClientConnected channel. The message will contain the client connection metadata.

The same will happen whenever a client subscribes a channel: a message containing the client connection metadata as well as the name of the subscribed channel will be published in the ortcClientSubscribed announcement channel.

Scaling using sub-channels

When you have a large number of announcements per second (>5.000) it’s a good scalability practice to use announcement sub-channels. You can use the announcement sub-channels feature by defining at the connection time an announcement sub-channel.

Let’s say your application is generating 15.000 announcements per second. Receiving this amount of messages per second in a single subscriber might be too much depending on the server and language you are using.

Let’s say we want to divide that throughput by 3 subscribers. By randomly selecting a sub-channel (1, 2 or 3) for each client connection will divide the total number of announcements (15.000) by three sub-channels, guaranteeing that a single subscriber can process the throughput of each sub-channel (~5.000 announcements/sub-channel). Obviously more elaborate algorithms can be implemented but the principle will be fairly the same: divide and conquer.

When you use announcement sub-channels you just add the sub-channel name to the announcement channel separating them using a colon (:)

For example, if for a specific client connection you define the announcement sub-channel 1 then this client connection announcement will be published at the ortcClientConnected:1 announcement channel. To receive this announcement simply subscribe the ortcClientConnected:1 channel. In fact the same will happen for all the other announcements for this client connection (e.g. if channel foo is subscribed than a client subscribed announcement will be published at the ortcClientSubscribed:1 announcement channel).

Complete list of announcement channels


Event: when a client connects

message = {"cm":"<YOUR_CONNECTION_METADATA>"}        


Event: when a client disconnects

// when a client disconnects normally
message = {"cm":"<YOUR_CONNECTION_METADATA>", "r": 0} 

// when a client connection timed out due to failed heartbearts
message = {"cm":"<YOUR_CONNECTION_METADATA>", "r": 1} 


Event: when a client subscribes a channel

message = {"cm":"<YOUR_CONNECTION_METADATA>","ch":"channelName"}  


Event: when a client unsubscribes a channel

message = {"cm":"<YOUR_CONNECTION_METADATA>","ch":"channelName"} 

Back to Presence - Next: Supported transports

If you find this interesting please share: