diff options
Diffstat (limited to 'lib/cli')
-rw-r--r-- | lib/cli/cli.ex | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/cli/cli.ex b/lib/cli/cli.ex index d2e5f6a..3f83cb1 100644 --- a/lib/cli/cli.ex +++ b/lib/cli/cli.ex @@ -33,24 +33,23 @@ defmodule SCLI do defp handle_command(pid, ["connect", ipstr, portstr]) do {:ok, ip} = :inet.parse_address (to_charlist ipstr) {port, _} = Integer.parse portstr - SNet.Manager.add_peer(ip, port) + Shard.Manager.add_peer(ip, port) pid end defp handle_command(pid, ["list"]) do IO.puts "List of known channels:" - list = GenServer.call(Shard.Manager, :list) - for {_chid, chpid} <- list do - {:chat, chan} = GenServer.call(chpid, :manifest) + + for {_chid, manifest, _chpid} <- :ets.tab2list(:shard_db) do + {:chat, chan} = manifest IO.puts "##{chan}" end pid end defp handle_command(pid, ["join", qchan]) do - list = GenServer.call(Shard.Manager, :list) - list = for {_chid, chpid} <- list, - {:chat, chan} = GenServer.call(chpid, :manifest), + list = for {_chid, manifest, chpid} <- :ets.tab2list(:shard_db), + {:chat, chan} = manifest, do: {chan, chpid} case List.keyfind(list, qchan, 0) do nil -> |