From a033c82a3c656a8f53feb60b5b149680771ac247 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 11 Sep 2018 15:39:09 +0200 Subject: Use DETS to store shard & peer list to disk --- shardweb/config/config.exs | 3 ++- shardweb/lib/shard_web/channels/room_channel.ex | 4 ++-- shardweb/lib/shard_web/templates/room/show.html.eex | 2 +- shardweb/lib/shard_web/views/page_view.ex | 2 +- shardweb/lib/shard_web/views/room_view.ex | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) (limited to 'shardweb') diff --git a/shardweb/config/config.exs b/shardweb/config/config.exs index 1b00d4e..c496d1d 100644 --- a/shardweb/config/config.exs +++ b/shardweb/config/config.exs @@ -20,7 +20,8 @@ config :logger, :console, # Configuration for Shard itself (see shard/config/config.exs for expanations) -config :shard, peer_id_suffix: "S" +config :shard, peer_id_suffix: "SH" +config :shard, data_path: Path.join [System.user_home, "shard", "data2"] # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. diff --git a/shardweb/lib/shard_web/channels/room_channel.ex b/shardweb/lib/shard_web/channels/room_channel.ex index 2dd733b..bb41a74 100644 --- a/shardweb/lib/shard_web/channels/room_channel.ex +++ b/shardweb/lib/shard_web/channels/room_channel.ex @@ -6,8 +6,8 @@ defmodule ShardWeb.RoomChannel do def join("room:" <> room_name, payload, socket) do if authorized?(payload) do - list = for {_chid, manifest, chpid} <- :ets.tab2list(:shard_db), - {:chat, chan} = manifest, + list = for {_chid, manifest, chpid} <- Shard.Manager.list_shards, + %SApp.Chat.Manifest{channel: chan} = manifest, do: {chan, chpid} pid = case List.keyfind(list, room_name, 0) do nil -> diff --git a/shardweb/lib/shard_web/templates/room/show.html.eex b/shardweb/lib/shard_web/templates/room/show.html.eex index a689017..5f28cc5 100644 --- a/shardweb/lib/shard_web/templates/room/show.html.eex +++ b/shardweb/lib/shard_web/templates/room/show.html.eex @@ -1,7 +1,7 @@