feat(server): agent socket endpoint, clear online status on boot
This commit is contained in:
parent
b141ee7816
commit
d9a52db4ea
3 changed files with 19 additions and 1 deletions
|
|
@ -24,7 +24,9 @@ defmodule Server.Application do
|
|||
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||
# for other strategies and supported options
|
||||
opts = [strategy: :one_for_one, name: Server.Supervisor]
|
||||
Supervisor.start_link(children, opts)
|
||||
result = Supervisor.start_link(children, opts)
|
||||
with {:ok, _} <- result, do: Server.Hosts.mark_all_offline()
|
||||
result
|
||||
end
|
||||
|
||||
# Tell Phoenix to update the endpoint configuration
|
||||
|
|
|
|||
12
server/lib/server_web/channels/agent_socket.ex
Normal file
12
server/lib/server_web/channels/agent_socket.ex
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
defmodule ServerWeb.AgentSocket do
|
||||
@moduledoc "Entry socket for agents. Actual authentication happens in HostChannel.join/3."
|
||||
use Phoenix.Socket
|
||||
|
||||
channel "host:*", ServerWeb.HostChannel
|
||||
|
||||
@impl true
|
||||
def connect(_params, socket, _connect_info), do: {:ok, socket}
|
||||
|
||||
@impl true
|
||||
def id(_socket), do: nil
|
||||
end
|
||||
|
|
@ -15,6 +15,10 @@ defmodule ServerWeb.Endpoint do
|
|||
websocket: [connect_info: [session: @session_options]],
|
||||
longpoll: [connect_info: [session: @session_options]]
|
||||
|
||||
socket "/socket", ServerWeb.AgentSocket,
|
||||
websocket: [timeout: 45_000],
|
||||
longpoll: false
|
||||
|
||||
# Serve at "/" the static files from "priv/static" directory.
|
||||
#
|
||||
# You should set gzip to true if you are running phx.digest
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue