Send and Receive Messages

A real-time system that can’t send and receive messages is probably not going to be very useful. We utilize Channel request handlers in order to process messages from a client or to send data to the client. This allows us to write handlers which are very similar to an action in a traditional MVC controller.

Before jumping right into sending messages, let’s look at the message protocol used to represent every client and server message, to get an idea of what is actually being sent to a client.

Phoenix Message Structure

Phoenix Channels use a simple message protocol to represent all messages to and from a client. The contents of the Message allow clients to keep track of the request and reply flow, which is important ...

Get Real-Time Phoenix now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.