Each application can have one channel or many, and each client can choose which channels it subscribes to.
- A way of filtering data. For example, in a chat application there may be a channel for people who want to discuss ‘dogs’
- A way of controlling access to different streams of information. For example, a project management application would want to authorise people to get updates about ‘secret-projectX’
We strongly recommend that channels are used to filter your data and that it is not achieved using events. This is because all events published to a channel are sent to all subscribers, regardless of their event binding.
Channels don’t need to be explicitly created, and are instantiated on client demand. This means that creating a channel is easy. Just tell a client to subscribe to it.
There are 3 types of channels at the moment:
- Public channels can be subscribed to by anyone who knows their name
- Private channels should have a
private-prefix. They introduce a mechanism which lets your server control access to the data you are broadcasting
- Presence channels should have a
presence-prefix and are an extension of private channels. They let you ‘register’ user information on subscription, and let other members of the channel know who’s online
Channel names may contain a maximum of 164 characters. This limit includes channel prefixes (i.e.
presence- are included in the character count).
Channel names should only include lower and uppercase letters, numbers and the following punctuation
_ - = @ , . ;
As an example this is a valid channel name:
If a channel has been subscribed to already it is possible to access channels by name, through the
var channel = pusher.channel(channelName);
- channelName (String)
- The name of the channel to retrieve