April 2018
Beginner to intermediate
406 pages
9h 33m
English
We should now start writing some data to ETS since we have all of the code and support in place to handle that! We'll also want to add a ChatCache.write(...) call in any place that we had any code that dealt with modifying Phoenix Presence data! Open up lib/vocial_web/channels/chat_channel.ex, and we'll start by adding a new alias to the top of our module to make accessing our ChatCache module a little easier:
alias Vocial.ChatCache
Next, our first function in our file that deals with Presence is our handle_in function for dealing with the user_idle status message, so we'll add a single line at the top of the function to handle that:
def handle_in("user_idle", %{"username" => username}, socket) do ChatCache.write(socket.topic, ...