abhiche
December 1, 2020, 5:11pm
#1
Hello everyone,
I am currently working with phoenix_gen_socket_client
defmodule Example.SocketClient do
@moduledoc false
require Logger
alias Phoenix.Channels.GenSocketClient
@behaviour GenSocketClient
def start_link() do
GenSocketClient.start_link(
__MODULE__,
Phoenix.Channels.GenSocketClient.Transport.WebSocketClient,
"ws://localhost:4000/socket/websocket"
)
end
def init(url) do
{:connect, url, [], %{first_join: true, ping_ref: 1}}
end
def handle_connected(transport, state) do
Logger.info("connected")
This file has been truncated. show original
I am able to connect and push messages to the websocket using the above module in the example when calling GenSocketClient.push
from inside the module.
How can I push messages from outside of this module?
Supervisor children config is:
children = [
%{
id: Example.SocketClient,
start: {Example.SocketClient, :start_link, []}
}
]