From b6cbd83d2812826ec4175c8984730f3daa28782b Mon Sep 17 00:00:00 2001 From: Serge Aleynikov Date: Thu, 7 Apr 2022 13:29:12 -0400 Subject: [PATCH 1/2] Add timeout option --- lib/websockex.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/websockex.ex b/lib/websockex.ex index 1ec6ca8..0027abe 100644 --- a/lib/websockex.ex +++ b/lib/websockex.ex @@ -410,7 +410,7 @@ defmodule WebSockex do error tuple with a `WebSockex.ConnError` exception struct as the second element. """ - @spec send_frame(client, frame) :: + @spec send_frame(client, frame, timeout) :: :ok | {:error, %WebSockex.FrameEncodeError{} @@ -418,11 +418,11 @@ defmodule WebSockex do | %WebSockex.NotConnectedError{} | %WebSockex.InvalidFrameError{}} | none - def send_frame(client, _) when client == self() do + def send_frame(client, _, _) when client == self() do raise %WebSockex.CallingSelfError{function: :send_frame} end - def send_frame(client, frame) do + def send_frame(client, frame, timeout \\ 10000) do try do {:ok, res} = :gen.call(client, :"$websockex_send", frame) res From 228792eaa953438a7fa81c40f91371d74ad4bec6 Mon Sep 17 00:00:00 2001 From: Serge Aleynikov Date: Thu, 23 Jun 2022 20:56:28 -0400 Subject: [PATCH 2/2] Update lib/websockex.ex Co-authored-by: Brendan Ball --- lib/websockex.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/websockex.ex b/lib/websockex.ex index 0027abe..fa0f549 100644 --- a/lib/websockex.ex +++ b/lib/websockex.ex @@ -424,7 +424,7 @@ defmodule WebSockex do def send_frame(client, frame, timeout \\ 10000) do try do - {:ok, res} = :gen.call(client, :"$websockex_send", frame) + {:ok, res} = :gen.call(client, :"$websockex_send", frame, timeout) res catch _, reason ->