Use a channel
To get started with implementing any feature, a client must first create or retrieve an instance of a channel. A channel is created, or an existing channel is retrieved from theChannels collection. You can only connect to one channel in a single operation.
Channels are identified by their unique name. The following restrictions apply to when naming a channel:
- Channel names are case sensitive
- They can’t start with
[or: - They can’t be empty
- They can’t contain newline characters
get() method to create or retrieve a channel instance:
Channel namespaces
Channels can be grouped together into a namespace. This enables you to apply operations to a namespace rather than each individual channel within it. A namespace is the first part of a channel name up to the first colon (:). If a channel name does not contain a colon, the namespace is the entire channel name. For example, the following channels are all part of the ‘customer’ namespace:
customercustomer:tracking-idcustomer:order:update
*.
Use channel namespaces to apply operations to all channels within that group, such as capabilities, channel rules and integrations.
Channel options
Channel options are used to customize the functionality of channels. This includes enabling features such as encryption and deltas, or for a client to retrieve messages published prior to it attaching to a channel using rewind.Channel rules
Channel rules can be used to enforce settings for specific channels, or channel namespaces. They can be broadly categorized into three different types:- For message storage
- For client security and identification
- To enable features for a channel or namespace
The channel rules related to security and client identity are:
To set a channel rule in the Ably dashboard:
- Sign in to your Ably account.
- Select an app.
- Go to Settings tab.
- Click Add new rule.
- Select channel name or namespace to apply rules to.
- Check required rules.
Next steps
- Learn how to publish messages
- Learn how to subscribe to messages
- Explore channel options
- Understand message format
