Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Websocket erlang牛仔网插座-开放式插座的数量_Websocket_Erlang_Cowboy - Fatal编程技术网

Websocket erlang牛仔网插座-开放式插座的数量

Websocket erlang牛仔网插座-开放式插座的数量,websocket,erlang,cowboy,Websocket,Erlang,Cowboy,我使用cowboy模块编写了一个Erlang聊天后端 我想知道如何记录当前连接的打开的web套接字连接数 我一直在寻找这个问题的答案,但我找不到答案 你知道怎么做吗 谢谢您的时间,请将您的websocket计入websocket\u init或websocket\u handle 我把公众的信息写在websocketets表格中 添加有关以下内容的信息websocket: websocket_handle({text, Msg}, Req, State) -> et

我使用cowboy模块编写了一个Erlang聊天后端

我想知道如何记录当前连接的打开的web套接字连接数

我一直在寻找这个问题的答案,但我找不到答案

你知道怎么做吗


谢谢您的时间,

请将您的websocket计入
websocket\u init
websocket\u handle
我把公众的信息写在websocket
ets
表格中

添加有关以下内容的信息websocket:

websocket_handle({text, Msg}, Req, State) ->
            ets:insert(systbl_websockets, {self(), get_current, other_info}),
            {reply, [{text, <<"ok">>}], Req, State, hibernate};
    end;
websocket_terminate(_Reason, _Req, _State) ->
    lager:debug("Close connection"),
    ets:delete(systbl_websockets, self()),
    {ok, _Req, _State, shutdown}.

请将您的websocket计入
websocket\u init
websocket\u handle
我把公众的信息写在websocket
ets
表格中

添加有关以下内容的信息websocket:

websocket_handle({text, Msg}, Req, State) ->
            ets:insert(systbl_websockets, {self(), get_current, other_info}),
            {reply, [{text, <<"ok">>}], Req, State, hibernate};
    end;
websocket_terminate(_Reason, _Req, _State) ->
    lager:debug("Close connection"),
    ets:delete(systbl_websockets, self()),
    {ok, _Req, _State, shutdown}.

我已经实现了一个计数器,在所有进程上迭代,初始调用{cowboy_protocol,init,4}这似乎可以正常工作fine@user1668328那个(过程迭代)在技术上听起来有点不可靠。至少,由于牛仔的变化,它可能很容易断裂。我必须说,我更喜欢回答者发布的解决方案。我已经实现了一个计数器,迭代所有进程,初始调用{cowboy_protocol,init,4}这似乎很有效fine@user1668328那个(过程迭代)在技术上听起来有点不可靠。至少,由于牛仔的变化,它可能很容易断裂。我不得不说,我更喜欢回答者发布的解决方案。