Permalink
Browse files

Add the chatroom

  • Loading branch information...
CrowdHailer committed May 28, 2018
1 parent 4cb1eff commit af92dba009cd032684fd1c228f2928913fd30faf
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/watercooler.ex
@@ -1,2 +1,18 @@
defmodule Watercooler do
@group :watercooler
def publish(message) do
:ok = :pg2.create(@group)
for client <- :pg2.get_members(@group) do
send(client, {@group, message})
end
{:ok, message}
end
def listen() do
:ok = :pg2.create(@group)
:ok = :pg2.join(@group, self())
{:ok, @group}
end
end

0 comments on commit af92dba

Please sign in to comment.