1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Integration.WebsocketClient do
6 # https://github.com/phoenixframework/phoenix/blob/master/test/support/websocket_client.exs
11 Starts the WebSocket server for given ws URL. Received Socket.Message's
12 are forwarded to the sender pid
14 def start_link(sender, url, headers \\ []) do
19 extra_headers: headers
31 Sends a low-level text message to the client.
33 def send_text(server_pid, msg) do
34 send(server_pid, {:text, msg})
39 def handle_frame(frame, state) do
40 send(state.sender, frame)
45 def handle_disconnect(conn_status, state) do
46 send(state.sender, {:close, conn_status})
52 def handle_info({:text, msg}, state) do
53 {:reply, {:text, msg}, state}
57 def handle_info(:close, _state) do
58 {:close, <<>>, "done"}
63 def terminate(_reason, _state) do