Implementation of a Channel
Follow step-by-step instructions to implement the Phoenix Channel.
Channels
Channels are the real-time entry points to our application’s logic and where most applications’ request handling code lives. A Channel has several different responsibilities to enable real-time applications:
- Accept or reject a request to join.
- Handle messages from the client.
- Handle messages from the PubSub.
- Push messages to the client.
Channels,Controllers, and Sockets
The distinction between Channels and Sockets may not be evident at a glance. A Socket’s responsibilities involve connection handling and routing requests to the correct Channel. A Channel’s responsibilities include handling requests from a client and sending data to a client. In this way, a Channel is similar to a Controller in the MVC (Model-View-Controller) ...