The underlying programming model for AppStax Realtime Channels is a publish/subscribe model, where a consumer subscribes to data pushed by a producer. The data pushed over a
named channel (e.g.,
public/newsfeed) is received by every consumer who has expressed an interest in receiving it by subscribing to that channel.
AppStax Realtime Channels uses websockets as the underlying transport mechanism. While you could certainly use websockets directly yourself, AppStax gives you many powerful features that enables more rapid development and deployment.
There are three types of realtime channels. Each of them serves a different use case.
Public channels are open to everyone. Data sent on a public channel will be made available to anyone who has subscribed.
Example use case:
Public channels are named within the namespace
public/. Example names are:
So, whenever a client sends a message to one of these channels, any client who has subscribed to the channel will receive the message.
Public channels do not have to be created or initialized in any way before they can be used. A public channel only exists to the extent that someone is a subscriber. This is in contrast to private channels.
It is possible for a client to subscribe to multiple channels that belong to the same root path. For example, in the list of sample public channels above, the following is a pattern subscription that will receive messages to both the
Unlike public channels, private channels must be explicitly created.
Example names are :
Private channels must be created by a particular enduser. They are then owned by that user. Only the owner of a private channel can grant
read/write permissions on the channel, in order for other endusers to publish/subscribe data.
Possible actions on private channels:
|channel.create||creates a private channel|
|channel.delete||deletes a private channel|
|grant.read||grants an enduser read/subscribe permissions on the channel|
|grant.write||grants an enduser write/publish permissions on the channel|
|publish||publish a message on the channel|
|subscribe||subscribe to messages on the channel|
|revoke.read||Revoke read/subscribe permissions on a private channel|
|revoke.write||revoke write/publish permissions on a private channel|
Private channels are persistent, in the sense that once created they will exist until they are deleted, regardless of whether the connection between the client and the server is closed.
Object channels are not explicitly created, but exist independent of any users. Each collection of objects has associated with it a channel through which various object events (
object.deleted are published).
Whenever an object in a specific collection is created, updated or deleted, an event is published to all subscribers. In this way it is possible for users (and a ServerCode module!) to be notified of any changes to objects in realtime, without polling the object storage.
Anyone can subscribe to events on a collection, but events are only available to those with access to the specific object (depending on collection and object permissions.)
|object.created||An object in the collection was created. The collection is given in the channel property.||
|object.updated||An object in the collection was updated||
|object.deleted||An object in the collection was deleted||
Example use cases:
Learn more about using AppStax Realtime Channels in these tutorials and guides: