Wrapping Up

In this chapter, you learned to build simple client/server APIs with Phoenix channels. Though the problem had many layers, it was easy to understand the flow because clients connected to servers, and both sides maintained the connection until the conversation was over. Along the way:

  • You learned to connect to a server-side channel through an ES6 client.

  • We built a server-side channel with both long-polling and WebSocket support.

  • We built a simple API to let users join a channel.

  • We processed inbound messages from OTP with handle_info and channels with handle_in.

  • We sent broadcast messages with broadcast!.

  • We authenticated users with Phoenix.Token.

  • We persisted annotations with Ecto.

Though channels are by far the most exciting feature ...

Get Programming 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.