diff options
author | Alex Auvolat <alex@adnab.me> | 2018-10-12 11:10:17 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-10-12 11:10:17 +0200 |
commit | d15d5fbfc5133a9d0f0d99dbbfc023849f61cc37 (patch) | |
tree | daedfd26af6978301b2633a338a137a874876d1f /shardweb/lib/shard_web | |
parent | 6dcc2eefc3c8db0cadd7300536527dbd1905fa48 (diff) | |
download | shard-d15d5fbfc5133a9d0f0d99dbbfc023849f61cc37.tar.gz shard-d15d5fbfc5133a9d0f0d99dbbfc023849f61cc37.zip |
Update TODO, refactor a bit
Diffstat (limited to 'shardweb/lib/shard_web')
-rw-r--r-- | shardweb/lib/shard_web/channels/room_channel.ex | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/shardweb/lib/shard_web/channels/room_channel.ex b/shardweb/lib/shard_web/channels/room_channel.ex index f582e06..7c3a16c 100644 --- a/shardweb/lib/shard_web/channels/room_channel.ex +++ b/shardweb/lib/shard_web/channels/room_channel.ex @@ -6,15 +6,7 @@ defmodule ShardWeb.RoomChannel do def join("room:" <> room_name, payload, socket) do if authorized?(payload) do - list = for {_chid, %SApp.Chat.Manifest{channel: chan}, chpid} <- Shard.Manager.list_shards, - do: {chan, chpid} - pid = case List.keyfind(list, room_name, 0) do - nil -> - {:ok, pid} = Shard.Manifest.start %SApp.Chat.Manifest{channel: room_name} - pid - {_, pid} -> - pid - end + pid = Shard.Manager.find_or_start %SApp.Chat.Manifest{channel: room_name} socket = assign(socket, :pid, pid) GenServer.cast(pid, {:subscribe, self()}) @@ -68,8 +60,8 @@ defmodule ShardWeb.RoomChannel do payload = Map.put(payload, "name", nick) payload = Map.put(payload, "pk16", Shard.Keys.pk_display pk) - broadcast socket, "shout", payload GenServer.cast(socket.assigns.pid, {:chat_send, pk, payload["message"]}) + broadcast socket, "shout", payload {:noreply, socket} end |