Messages are always sent through PubNub on a channel. Users that subscribe to a channel will receive messages that are published on that channel. Users can subscribe to a single channel or thousands of channels simultaneously through a single open connection. Messages are always published to a single channel.
Channels are uniquely identified by a string. Channels are lightweight and exist merely by using them. Publish or subscribe to a channel name and it exists. There is no additional configuration or setup required.
It's your responsibility to coordinate that message senders and message receivers know which channels to use and what types of messages to send.
One way to coordinate channel names is to use a persistence mechanism to store which channels a user should subscribe to. The channel list concept is common in chat applications.
Another way to do this is to agree on a channel naming convention. Refer to Channel Naming Conventions in Manage Channels for more information.
Some applications may only use a small, fixed set of channels that can be coded into the application. For example, the applications in the chat quickstart use only a single hard-coded channel.
By default, channels are open to all users on the application. PubNub Access Manager (PAM) can be enabled to restrict user access to channels to ensure privacy for communication on certain channels. Both read and write access to any channel can be controlled for any user.
Refer to Authorization section for more information.
Associating data with a channel
Many chat applications have data associated with a channel, like a description of the chat room or an icon. Other entities might also be associated with a channel, such as the list of channels a user is subscribed to, or a list of pinned topics in a chat room. Channels in PubNub are lightweight and transient by design, so if you need to store this type of data, it's your responsibility to set up a persistent data store.