从Erlang连接到Phoenix频道

时间:2019-02-28 21:30:56

标签: erlang phoenix-framework

我正在尝试从Erlang节点连接到Phoenix频道。我的发电服务器看起来像下面的东西,当我运行它时我没事。但是我没有听到任何来自凤凰频道/服务器的消息。我正在使用handle_call,handle_cast和handle_info来侦听来自凤凰城的消息,是否需要更改handle_call,handle_message和handle_info的一致性?请帮助

start_link() -> 
process_flag(trap_exit, true),

    URL = "ws://localhost:14000/<my_channel_name>/websocket",
   'Elixir.Phoenix.Channels.GenSocketClient':start_link(
        ?MODULE, 'Elixir.Phoenix.Channels.GenSocketClient.Transport.WebSocketClient', URL, [{user_id, atom_to_list(node())}], [{name, '<my_socket_client>'}]
    ).


init(URL) ->
    'Elixir.Agent':start_link(fun() -> #{} end, [{name, '<my_agent_name>'}]),
    {ok, [{connect, URL, [{"user_id", atom_to_list(node())}], #{}}]}.

handle_call(_Request, _From, State) ->
    {reply, dummy, State}.

handle_cast(_Request, State) ->
    {noreply, State}.

handle_info(Info, State) ->
    {noreply, Info, State}.

terminate(_reason, _State) ->
    ok.

code_change(_OldVersion, State, _Extra) ->
    {ok, State}.

0 个答案:

没有答案