aboutsummaryrefslogtreecommitdiff
path: root/shardweb/lib/channels/chat_channel.ex
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-10-12 18:16:46 +0200
committerAlex Auvolat <alex@adnab.me>2018-10-12 18:16:46 +0200
commit574b572fac144135c4381581351445bf5d0de81c (patch)
tree1ad2fa0157583a955069332e6a957250ff362967 /shardweb/lib/channels/chat_channel.ex
parent7bc609a85b43ed86eccb9cd40d9db31f15aaba1d (diff)
downloadshard-574b572fac144135c4381581351445bf5d0de81c.tar.gz
shard-574b572fac144135c4381581351445bf5d0de81c.zip
Clean up interface to shards0.0.3
Diffstat (limited to 'shardweb/lib/channels/chat_channel.ex')
-rw-r--r--shardweb/lib/channels/chat_channel.ex14
1 files changed, 7 insertions, 7 deletions
diff --git a/shardweb/lib/channels/chat_channel.ex b/shardweb/lib/channels/chat_channel.ex
index a413be1..25f1d09 100644
--- a/shardweb/lib/channels/chat_channel.ex
+++ b/shardweb/lib/channels/chat_channel.ex
@@ -9,7 +9,7 @@ defmodule ShardWeb.ChatChannel do
pid = Shard.Manager.find_or_start %SApp.Chat.Manifest{channel: room_name}
socket = assign(socket, :pid, pid)
- GenServer.cast(pid, {:subscribe, self()})
+ SApp.Chat.subscribe(pid)
send(self(), :after_join)
{:ok, socket}
@@ -27,7 +27,7 @@ defmodule ShardWeb.ChatChannel do
pid = Shard.Manager.find_or_start(SApp.Chat.PrivChat.Manifest.new(pk_list))
socket = assign(socket, :pid, pid)
- GenServer.cast(pid, {:subscribe, self()})
+ SApp.Chat.subscribe(pid)
send(self(), :after_join)
{:ok, socket}
@@ -37,7 +37,7 @@ defmodule ShardWeb.ChatChannel do
end
def handle_info(:after_join, socket) do
- GenServer.call(socket.assigns.pid, {:read_history, nil, 100})
+ SApp.Chat.read_history(socket.assigns.pid, nil, 100)
|> Enum.each(fn {{pk, msgbin, _sign}, true} ->
{_ts, msg} = SData.term_unbin msgbin
nick = SApp.Identity.get_nick pk
@@ -47,7 +47,7 @@ defmodule ShardWeb.ChatChannel do
message: msg,
})
end)
- GenServer.cast(socket.assigns.pid, :mark_read)
+ SApp.Chat.mark_read(socket.assigns.pid)
{:noreply, socket}
end
@@ -58,12 +58,12 @@ defmodule ShardWeb.ChatChannel do
push socket, "shout", %{"name" => nick,
"pk16" => Shard.Keys.pk_display(pk),
"message" => msg}
- GenServer.cast(socket.assigns.pid, :mark_read)
+ SApp.Chat.mark_read(socket.assigns.pid)
{:noreply, socket}
end
def handle_info({:chat_send, _, _}, socket) do
- GenServer.cast(socket.assigns.pid, :mark_read)
+ SApp.Chat.mark_read(socket.assigns.pid)
{:noreply, socket}
end
@@ -81,7 +81,7 @@ defmodule ShardWeb.ChatChannel do
payload = Map.put(payload, "name", nick)
payload = Map.put(payload, "pk16", Shard.Keys.pk_display pk)
- GenServer.cast(socket.assigns.pid, {:chat_send, pk, payload["message"]})
+ SApp.Chat.chat_send(socket.assigns.pid, pk, payload["message"])
broadcast socket, "shout", payload
{:noreply, socket}
end