Channels

Channels are a fundamental concept in Pusher. Each application has a number of channels, and every client can choose which channels it connects to.

Channels provide:

  • 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.

Channel Types

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 Naming Conventions

Channel names should only include lower and uppercase letters, numbers and the following punctuation _ - = @ , . ;

As an example this is a valid channel name:

foo-bar_1234@=,.;

Accessing channels

If a channel has been subscribed to already it is possible to access channels by name, through the pusher.channel function:

var channel = pusher.channel(channelName);
  • channelName (String)
    • The name of the channel to retrieve

Have you tried using the search to find what you’re after? If you still have a question then get in touch with us and let us help you out.