mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-06 15:37:52 +01:00
19 lines
312 B
Erlang
19 lines
312 B
Erlang
-module (websocket_test).
|
|
-export([start/1, loop/1]).
|
|
|
|
% callback on received websockets data
|
|
start(Ws) ->
|
|
spawn(?MODULE, loop, [Ws]).
|
|
|
|
loop(Ws) ->
|
|
receive
|
|
{browser, Data} ->
|
|
Ws:send(["received '", Data, "'"]),
|
|
loop(Ws);
|
|
_Ignore ->
|
|
loop(Ws)
|
|
after 5000 ->
|
|
Ws:send("pushing!"),
|
|
loop(Ws)
|
|
end.
|