mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-27 00:09:35 +00:00
streamline Streamer pings
This commit is contained in:
parent
15ef521009
commit
574856ef01
|
@ -35,28 +35,21 @@ defmodule Pleroma.Web.Streamer do
|
||||||
end
|
end
|
||||||
|
|
||||||
def init(args) do
|
def init(args) do
|
||||||
spawn(fn ->
|
Process.send_after(self(), %{action: :ping}, @keepalive_interval)
|
||||||
# 30 seconds
|
|
||||||
Process.sleep(@keepalive_interval)
|
|
||||||
GenServer.cast(__MODULE__, %{action: :ping})
|
|
||||||
end)
|
|
||||||
|
|
||||||
{:ok, args}
|
{:ok, args}
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_cast(%{action: :ping}, topics) do
|
def handle_info(%{action: :ping}, topics) do
|
||||||
Map.values(topics)
|
topics
|
||||||
|
|> Map.values()
|
||||||
|> List.flatten()
|
|> List.flatten()
|
||||||
|> Enum.each(fn socket ->
|
|> Enum.each(fn socket ->
|
||||||
Logger.debug("Sending keepalive ping")
|
Logger.debug("Sending keepalive ping")
|
||||||
send(socket.transport_pid, {:text, ""})
|
send(socket.transport_pid, {:text, ""})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
spawn(fn ->
|
Process.send_after(self(), %{action: :ping}, @keepalive_interval)
|
||||||
# 30 seconds
|
|
||||||
Process.sleep(@keepalive_interval)
|
|
||||||
GenServer.cast(__MODULE__, %{action: :ping})
|
|
||||||
end)
|
|
||||||
|
|
||||||
{:noreply, topics}
|
{:noreply, topics}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue