April 2018
Beginner to intermediate
406 pages
9h 33m
English
To start implementing chat in our application, we'll need to start building out the chat channel and setting up all of the framework code necessary for us to support the new channel. We'll need to start by adding the new channel to lib/vocial_web/channels/user_socket.ex:
channel "chat:*", VocialWeb.ChatChannel
We don't actually have a Chat Channel module yet, so that will be the next file that we will have to start building up. In the same directory, we'll create a chat_channel.ex file and start it off with a simple channel skeleton:
defmodule VocialWeb.ChatChannel do use VocialWeb, :channel def join("chat:lobby", _payload, socket) do {:ok, socket} endend
We'll also have to refactor our JavaScript in the socket.js ...