2024-05-28 18:27:02 -04:00
|
|
|
defmodule ChronoscopeWeb.IndexLive do
|
|
|
|
use ChronoscopeWeb, :live_view
|
|
|
|
|
2024-05-29 15:25:05 -04:00
|
|
|
alias Chronoscope.NTS
|
2024-06-01 10:30:35 -04:00
|
|
|
alias Chronoscope.NTS.KeyEstablishmentResponse
|
2024-05-29 15:25:05 -04:00
|
|
|
|
2024-06-04 20:03:02 -04:00
|
|
|
@topic Application.compile_env(:chronoscope, :nts_topic)
|
2024-05-28 18:27:02 -04:00
|
|
|
|
|
|
|
def mount(_params, _session, socket) do
|
|
|
|
ChronoscopeWeb.Endpoint.subscribe(@topic)
|
2024-06-04 20:03:02 -04:00
|
|
|
{:ok, assign(socket, %{servers: server_list()})}
|
2024-05-28 18:27:02 -04:00
|
|
|
end
|
|
|
|
|
2024-05-29 16:25:27 -04:00
|
|
|
def handle_info(%{topic: @topic}, socket) do
|
2024-06-04 20:03:02 -04:00
|
|
|
{:noreply, assign(socket, %{servers: server_list()})}
|
|
|
|
end
|
|
|
|
|
|
|
|
defp server_list() do
|
|
|
|
Chronoscope.Monitor
|
|
|
|
|> GenServer.call(:get_nts_servers)
|
|
|
|
|> NTS.list_clients()
|
2024-05-28 18:27:02 -04:00
|
|
|
end
|
|
|
|
end
|