From e9b7d2409f6700a795dfd85240c960198954b968 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Fri, 22 Jul 2022 15:36:15 +0100 Subject: [PATCH] ping-pong --- lib/pleroma/web/mastodon_api/websocket_handler.ex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pleroma/web/mastodon_api/websocket_handler.ex b/lib/pleroma/web/mastodon_api/websocket_handler.ex index b978167b6..327be6839 100644 --- a/lib/pleroma/web/mastodon_api/websocket_handler.ex +++ b/lib/pleroma/web/mastodon_api/websocket_handler.ex @@ -64,6 +64,10 @@ defmodule Pleroma.Web.MastodonAPI.WebsocketHandler do # We only receive pings for now def websocket_handle(:ping, state), do: {:ok, state} + def websocket_handle({:text, "ping"}, state) do + if state.timer, do: Process.cancel_timer(state.timer) + {:reply, {:text, "pong"}, %{state | timer: timer()}} + end def websocket_handle(frame, state) do Logger.error("#{__MODULE__} received frame: #{inspect(frame)}")