Skip to Content
Phoenix Web Development
book

Phoenix Web Development

by Brandon Richey
April 2018
Beginner to intermediate content levelBeginner to intermediate
406 pages
9h 33m
English
Packt Publishing
Content preview from Phoenix Web Development

Storing Presence data in ETS

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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Phoenix in Action

Phoenix in Action

Geoffrey Lessel
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9781787284197Supplemental Content