2015-02-25 10:42:59 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
%%% File : ejabberd_websocket.erl
|
|
|
|
%%% Author : Eric Cestari <ecestari@process-one.net>
|
|
|
|
%%% Purpose : XMPP Websocket support
|
|
|
|
%%% Created : 09-10-2010 by Eric Cestari <ecestari@process-one.net>
|
|
|
|
%%%
|
|
|
|
%%%
|
2018-01-05 21:18:58 +01:00
|
|
|
%%% ejabberd, Copyright (C) 2002-2018 ProcessOne
|
2015-02-25 10:42:59 +01:00
|
|
|
%%%
|
|
|
|
%%% This program is free software; you can redistribute it and/or
|
|
|
|
%%% modify it under the terms of the GNU General Public License as
|
|
|
|
%%% published by the Free Software Foundation; either version 2 of the
|
|
|
|
%%% License, or (at your option) any later version.
|
|
|
|
%%%
|
|
|
|
%%% This program is distributed in the hope that it will be useful,
|
|
|
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
%%% General Public License for more details.
|
|
|
|
%%%
|
2015-02-25 15:19:33 +01:00
|
|
|
%%% You should have received a copy of the GNU General Public License along
|
|
|
|
%%% with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2015-02-25 10:42:59 +01:00
|
|
|
%%%
|
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
-module(ejabberd_http_ws).
|
|
|
|
|
2015-06-01 14:38:27 +02:00
|
|
|
-behaviour(ejabberd_config).
|
|
|
|
|
2015-02-25 10:42:59 +01:00
|
|
|
-author('ecestari@process-one.net').
|
|
|
|
|
2017-08-05 19:58:21 +02:00
|
|
|
-behaviour(p1_fsm).
|
2015-02-25 10:42:59 +01:00
|
|
|
|
|
|
|
-export([start/1, start_link/1, init/1, handle_event/3,
|
|
|
|
handle_sync_event/4, code_change/4, handle_info/3,
|
2015-06-01 14:38:27 +02:00
|
|
|
terminate/3, send_xml/2, setopts/2, sockname/1,
|
|
|
|
peername/1, controlling_process/2, become_controller/2,
|
2017-12-26 16:55:57 +01:00
|
|
|
monitor/1, reset_stream/1, close/1, change_shaper/2,
|
2018-05-14 18:30:21 +02:00
|
|
|
socket_handoff/3, opt_type/1]).
|
2015-02-25 10:42:59 +01:00
|
|
|
|
|
|
|
-include("ejabberd.hrl").
|
|
|
|
-include("logger.hrl").
|
|
|
|
|
2016-07-30 17:37:57 +02:00
|
|
|
-include("xmpp.hrl").
|
2015-02-25 10:42:59 +01:00
|
|
|
|
|
|
|
-include("ejabberd_http.hrl").
|
|
|
|
|
|
|
|
-define(PING_INTERVAL, 60).
|
|
|
|
-define(WEBSOCKET_TIMEOUT, 300).
|
|
|
|
|
|
|
|
-record(state,
|
|
|
|
{socket :: ws_socket(),
|
2015-03-12 10:34:23 +01:00
|
|
|
ping_interval = ?PING_INTERVAL :: non_neg_integer(),
|
2015-02-25 10:42:59 +01:00
|
|
|
ping_timer = make_ref() :: reference(),
|
2017-02-18 07:36:27 +01:00
|
|
|
pong_expected = false :: boolean(),
|
2015-03-12 10:34:23 +01:00
|
|
|
timeout = ?WEBSOCKET_TIMEOUT :: non_neg_integer(),
|
2015-02-25 10:42:59 +01:00
|
|
|
timer = make_ref() :: reference(),
|
|
|
|
input = [] :: list(),
|
|
|
|
waiting_input = false :: false | pid(),
|
2017-02-18 07:36:27 +01:00
|
|
|
last_receiver = self() :: pid(),
|
2015-02-25 10:42:59 +01:00
|
|
|
ws :: {#ws{}, pid()},
|
|
|
|
rfc_compilant = undefined :: boolean() | undefined}).
|
|
|
|
|
|
|
|
%-define(DBGFSM, true).
|
|
|
|
|
|
|
|
-ifdef(DBGFSM).
|
|
|
|
|
|
|
|
-define(FSMOPTS, [{debug, [trace]}]).
|
|
|
|
|
|
|
|
-else.
|
|
|
|
|
|
|
|
-define(FSMOPTS, []).
|
|
|
|
|
|
|
|
-endif.
|
|
|
|
|
|
|
|
-type ws_socket() :: {http_ws, pid(), {inet:ip_address(), inet:port_number()}}.
|
|
|
|
-export_type([ws_socket/0]).
|
|
|
|
|
|
|
|
start(WS) ->
|
2017-08-05 19:58:21 +02:00
|
|
|
p1_fsm:start(?MODULE, [WS], ?FSMOPTS).
|
2015-02-25 10:42:59 +01:00
|
|
|
|
|
|
|
start_link(WS) ->
|
2017-08-05 19:58:21 +02:00
|
|
|
p1_fsm:start_link(?MODULE, [WS], ?FSMOPTS).
|
2015-02-25 10:42:59 +01:00
|
|
|
|
|
|
|
send_xml({http_ws, FsmRef, _IP}, Packet) ->
|
2017-08-05 19:58:21 +02:00
|
|
|
case catch p1_fsm:sync_send_all_state_event(FsmRef,
|
2017-06-23 17:19:28 +02:00
|
|
|
{send_xml, Packet},
|
|
|
|
15000)
|
|
|
|
of
|
|
|
|
{'EXIT', {timeout, _}} -> {error, timeout};
|
|
|
|
{'EXIT', _} -> {error, einval};
|
|
|
|
Res -> Res
|
|
|
|
end.
|
2015-02-25 10:42:59 +01:00
|
|
|
|
|
|
|
setopts({http_ws, FsmRef, _IP}, Opts) ->
|
|
|
|
case lists:member({active, once}, Opts) of
|
|
|
|
true ->
|
2017-08-05 19:58:21 +02:00
|
|
|
p1_fsm:send_all_state_event(FsmRef,
|
2015-02-25 10:42:59 +01:00
|
|
|
{activate, self()});
|
|
|
|
_ -> ok
|
|
|
|
end.
|
|
|
|
|
|
|
|
sockname(_Socket) -> {ok, {{0, 0, 0, 0}, 0}}.
|
|
|
|
|
|
|
|
peername({http_ws, _FsmRef, IP}) -> {ok, IP}.
|
|
|
|
|
|
|
|
controlling_process(_Socket, _Pid) -> ok.
|
|
|
|
|
|
|
|
become_controller(FsmRef, C2SPid) ->
|
2017-12-26 16:55:57 +01:00
|
|
|
p1_fsm:send_all_state_event(FsmRef, {activate, C2SPid}).
|
2015-02-25 10:42:59 +01:00
|
|
|
|
|
|
|
close({http_ws, FsmRef, _IP}) ->
|
2017-08-05 19:58:21 +02:00
|
|
|
catch p1_fsm:sync_send_all_state_event(FsmRef, close).
|
2015-02-25 10:42:59 +01:00
|
|
|
|
2017-12-26 16:55:57 +01:00
|
|
|
monitor({http_ws, FsmRef, _IP}) ->
|
|
|
|
erlang:monitor(process, FsmRef).
|
|
|
|
|
|
|
|
reset_stream({http_ws, _FsmRef, _IP} = Socket) ->
|
|
|
|
Socket.
|
|
|
|
|
|
|
|
change_shaper({http_ws, _FsmRef, _IP}, _Shaper) ->
|
|
|
|
%% TODO???
|
|
|
|
ok.
|
|
|
|
|
2018-05-14 18:30:21 +02:00
|
|
|
socket_handoff(LocalPath, Request, Opts) ->
|
|
|
|
ejabberd_websocket:socket_handoff(LocalPath, Request, Opts, ?MODULE, fun get_human_html_xmlel/0).
|
2015-02-25 10:42:59 +01:00
|
|
|
|
|
|
|
%%% Internal
|
|
|
|
|
2015-09-04 12:42:53 +02:00
|
|
|
init([{#ws{ip = IP, http_opts = HOpts}, _} = WS]) ->
|
2016-08-22 20:59:39 +02:00
|
|
|
SOpts = lists:filtermap(fun({stream_management, _}) -> true;
|
2015-09-04 12:42:53 +02:00
|
|
|
({max_ack_queue, _}) -> true;
|
2016-09-07 23:16:54 +02:00
|
|
|
({ack_timeout, _}) -> true;
|
2015-09-04 12:42:53 +02:00
|
|
|
({resume_timeout, _}) -> true;
|
2015-09-17 00:33:08 +02:00
|
|
|
({max_resume_timeout, _}) -> true;
|
2015-09-04 12:42:53 +02:00
|
|
|
({resend_on_timeout, _}) -> true;
|
2018-04-12 17:42:59 +02:00
|
|
|
({access, _}) -> true;
|
2015-09-04 12:42:53 +02:00
|
|
|
(_) -> false
|
|
|
|
end, HOpts),
|
2017-01-09 15:02:17 +01:00
|
|
|
Opts = ejabberd_c2s_config:get_c2s_limits() ++ SOpts,
|
2015-02-25 10:42:59 +01:00
|
|
|
PingInterval = ejabberd_config:get_option(
|
|
|
|
{websocket_ping_interval, ?MYNAME},
|
|
|
|
?PING_INTERVAL) * 1000,
|
|
|
|
WSTimeout = ejabberd_config:get_option(
|
|
|
|
{websocket_timeout, ?MYNAME},
|
|
|
|
?WEBSOCKET_TIMEOUT) * 1000,
|
|
|
|
Socket = {http_ws, self(), IP},
|
|
|
|
?DEBUG("Client connected through websocket ~p",
|
|
|
|
[Socket]),
|
2017-12-26 16:55:57 +01:00
|
|
|
xmpp_socket:start(ejabberd_c2s, ?MODULE, Socket,
|
|
|
|
[{receiver, self()}|Opts]),
|
2015-02-25 10:42:59 +01:00
|
|
|
Timer = erlang:start_timer(WSTimeout, self(), []),
|
|
|
|
{ok, loop,
|
|
|
|
#state{socket = Socket, timeout = WSTimeout,
|
|
|
|
timer = Timer, ws = WS,
|
|
|
|
ping_interval = PingInterval}}.
|
|
|
|
|
|
|
|
handle_event({activate, From}, StateName, StateData) ->
|
|
|
|
case StateData#state.input of
|
|
|
|
[] ->
|
|
|
|
{next_state, StateName,
|
|
|
|
StateData#state{waiting_input = From}};
|
|
|
|
Input ->
|
|
|
|
Receiver = From,
|
2015-04-09 13:35:37 +02:00
|
|
|
lists:foreach(fun(I) when is_binary(I)->
|
|
|
|
Receiver ! {tcp, StateData#state.socket, I};
|
|
|
|
(I2) ->
|
|
|
|
Receiver ! {tcp, StateData#state.socket, [I2]}
|
2015-04-06 17:54:45 +02:00
|
|
|
end, Input),
|
2015-02-25 10:42:59 +01:00
|
|
|
{next_state, StateName,
|
|
|
|
StateData#state{input = [], waiting_input = false,
|
|
|
|
last_receiver = Receiver}}
|
|
|
|
end.
|
|
|
|
|
|
|
|
handle_sync_event({send_xml, Packet}, _From, StateName,
|
|
|
|
#state{ws = {_, WsPid}, rfc_compilant = R} = StateData) ->
|
|
|
|
Packet2 = case {case R of undefined -> true; V -> V end, Packet} of
|
|
|
|
{true, {xmlstreamstart, _, Attrs}} ->
|
|
|
|
Attrs2 = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>} |
|
|
|
|
lists:keydelete(<<"xmlns">>, 1, lists:keydelete(<<"xmlns:stream">>, 1, Attrs))],
|
|
|
|
{xmlstreamelement, #xmlel{name = <<"open">>, attrs = Attrs2}};
|
|
|
|
{true, {xmlstreamend, _}} ->
|
|
|
|
{xmlstreamelement, #xmlel{name = <<"close">>,
|
|
|
|
attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]}};
|
|
|
|
{true, {xmlstreamraw, <<"\r\n\r\n">>}} -> % cdata ping
|
|
|
|
skip;
|
|
|
|
{true, {xmlstreamelement, #xmlel{name=Name2} = El2}} ->
|
|
|
|
El3 = case Name2 of
|
|
|
|
<<"stream:", _/binary>> ->
|
2016-02-03 19:03:17 +01:00
|
|
|
fxml:replace_tag_attr(<<"xmlns:stream">>, ?NS_STREAM, El2);
|
2015-02-25 10:42:59 +01:00
|
|
|
_ ->
|
2016-02-03 19:03:17 +01:00
|
|
|
case fxml:get_tag_attr_s(<<"xmlns">>, El2) of
|
2015-02-25 10:42:59 +01:00
|
|
|
<<"">> ->
|
2016-02-03 19:03:17 +01:00
|
|
|
fxml:replace_tag_attr(<<"xmlns">>, <<"jabber:client">>, El2);
|
2015-02-25 10:42:59 +01:00
|
|
|
_ ->
|
|
|
|
El2
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
{xmlstreamelement , El3};
|
|
|
|
_ ->
|
|
|
|
Packet
|
|
|
|
end,
|
|
|
|
case Packet2 of
|
|
|
|
{xmlstreamstart, Name, Attrs3} ->
|
2016-02-03 19:03:17 +01:00
|
|
|
B = fxml:element_to_binary(#xmlel{name = Name, attrs = Attrs3}),
|
2015-02-25 10:42:59 +01:00
|
|
|
WsPid ! {send, <<(binary:part(B, 0, byte_size(B)-2))/binary, ">">>};
|
|
|
|
{xmlstreamend, Name} ->
|
|
|
|
WsPid ! {send, <<"</", Name/binary, ">">>};
|
|
|
|
{xmlstreamelement, El} ->
|
2016-02-03 19:03:17 +01:00
|
|
|
WsPid ! {send, fxml:element_to_binary(El)};
|
2015-02-25 10:42:59 +01:00
|
|
|
{xmlstreamraw, Bin} ->
|
|
|
|
WsPid ! {send, Bin};
|
|
|
|
{xmlstreamcdata, Bin2} ->
|
|
|
|
WsPid ! {send, Bin2};
|
|
|
|
skip ->
|
|
|
|
ok
|
|
|
|
end,
|
2015-03-25 17:08:43 +01:00
|
|
|
SN2 = case Packet2 of
|
|
|
|
{xmlstreamelement, #xmlel{name = <<"close">>}} ->
|
|
|
|
stream_end_sent;
|
|
|
|
_ ->
|
|
|
|
StateName
|
|
|
|
end,
|
|
|
|
{reply, ok, SN2, StateData};
|
|
|
|
handle_sync_event(close, _From, StateName, #state{ws = {_, WsPid}, rfc_compilant = true} = StateData)
|
|
|
|
when StateName /= stream_end_sent ->
|
|
|
|
Close = #xmlel{name = <<"close">>,
|
|
|
|
attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]},
|
2016-02-03 19:03:17 +01:00
|
|
|
WsPid ! {send, fxml:element_to_binary(Close)},
|
2015-03-25 17:08:43 +01:00
|
|
|
{stop, normal, StateData};
|
2015-02-25 10:42:59 +01:00
|
|
|
handle_sync_event(close, _From, _StateName, StateData) ->
|
|
|
|
{stop, normal, StateData}.
|
|
|
|
|
|
|
|
handle_info(closed, _StateName, StateData) ->
|
|
|
|
{stop, normal, StateData};
|
|
|
|
handle_info({received, Packet}, StateName, StateDataI) ->
|
|
|
|
{StateData, Parsed} = parse(StateDataI, Packet),
|
|
|
|
SD = case StateData#state.waiting_input of
|
|
|
|
false ->
|
2015-04-06 17:54:45 +02:00
|
|
|
Input = StateData#state.input ++ if is_binary(Parsed) -> [Parsed]; true -> Parsed end,
|
2015-02-25 10:42:59 +01:00
|
|
|
StateData#state{input = Input};
|
|
|
|
Receiver ->
|
|
|
|
Receiver ! {tcp, StateData#state.socket, Parsed},
|
|
|
|
setup_timers(StateData#state{waiting_input = false,
|
|
|
|
last_receiver = Receiver})
|
|
|
|
end,
|
|
|
|
{next_state, StateName, SD};
|
|
|
|
handle_info(PingPong, StateName, StateData) when PingPong == ping orelse
|
|
|
|
PingPong == pong ->
|
|
|
|
StateData2 = setup_timers(StateData),
|
|
|
|
{next_state, StateName,
|
|
|
|
StateData2#state{pong_expected = false}};
|
|
|
|
handle_info({timeout, Timer, _}, _StateName,
|
|
|
|
#state{timer = Timer} = StateData) ->
|
2017-07-13 10:49:35 +02:00
|
|
|
?DEBUG("Closing websocket connection from hitting inactivity timeout", []),
|
2015-02-25 10:42:59 +01:00
|
|
|
{stop, normal, StateData};
|
|
|
|
handle_info({timeout, Timer, _}, StateName,
|
|
|
|
#state{ping_timer = Timer, ws = {_, WsPid}} = StateData) ->
|
|
|
|
case StateData#state.pong_expected of
|
|
|
|
false ->
|
|
|
|
cancel_timer(StateData#state.ping_timer),
|
|
|
|
PingTimer = erlang:start_timer(StateData#state.ping_interval,
|
|
|
|
self(), []),
|
|
|
|
WsPid ! {ping, <<>>},
|
|
|
|
{next_state, StateName,
|
|
|
|
StateData#state{ping_timer = PingTimer, pong_expected = true}};
|
|
|
|
true ->
|
2017-07-13 10:49:35 +02:00
|
|
|
?DEBUG("Closing websocket connection from missing pongs", []),
|
2015-02-25 10:42:59 +01:00
|
|
|
{stop, normal, StateData}
|
|
|
|
end;
|
|
|
|
handle_info(_, StateName, StateData) ->
|
|
|
|
{next_state, StateName, StateData}.
|
|
|
|
|
|
|
|
code_change(_OldVsn, StateName, StateData, _Extra) ->
|
|
|
|
{ok, StateName, StateData}.
|
|
|
|
|
|
|
|
terminate(_Reason, _StateName, StateData) ->
|
|
|
|
case StateData#state.waiting_input of
|
|
|
|
false -> ok;
|
|
|
|
Receiver ->
|
|
|
|
?DEBUG("C2S Pid : ~p", [Receiver]),
|
|
|
|
Receiver ! {tcp_closed, StateData#state.socket}
|
|
|
|
end,
|
|
|
|
ok.
|
|
|
|
|
|
|
|
setup_timers(StateData) ->
|
|
|
|
cancel_timer(StateData#state.timer),
|
|
|
|
Timer = erlang:start_timer(StateData#state.timeout,
|
|
|
|
self(), []),
|
|
|
|
cancel_timer(StateData#state.ping_timer),
|
2015-08-05 16:08:06 +02:00
|
|
|
PingTimer = case StateData#state.ping_interval of
|
|
|
|
0 -> StateData#state.ping_timer;
|
|
|
|
V -> erlang:start_timer(V, self(), [])
|
2015-02-25 10:42:59 +01:00
|
|
|
end,
|
|
|
|
StateData#state{timer = Timer, ping_timer = PingTimer,
|
|
|
|
pong_expected = false}.
|
|
|
|
|
|
|
|
cancel_timer(Timer) ->
|
|
|
|
erlang:cancel_timer(Timer),
|
|
|
|
receive {timeout, Timer, _} -> ok after 0 -> ok end.
|
|
|
|
|
|
|
|
get_human_html_xmlel() ->
|
2017-04-11 12:13:58 +02:00
|
|
|
Heading = <<"ejabberd ", (misc:atom_to_binary(?MODULE))/binary>>,
|
2015-02-25 10:42:59 +01:00
|
|
|
#xmlel{name = <<"html">>,
|
|
|
|
attrs =
|
|
|
|
[{<<"xmlns">>, <<"http://www.w3.org/1999/xhtml">>}],
|
|
|
|
children =
|
|
|
|
[#xmlel{name = <<"head">>, attrs = [],
|
|
|
|
children =
|
|
|
|
[#xmlel{name = <<"title">>, attrs = [],
|
|
|
|
children = [{xmlcdata, Heading}]}]},
|
|
|
|
#xmlel{name = <<"body">>, attrs = [],
|
|
|
|
children =
|
|
|
|
[#xmlel{name = <<"h1">>, attrs = [],
|
|
|
|
children = [{xmlcdata, Heading}]},
|
|
|
|
#xmlel{name = <<"p">>, attrs = [],
|
|
|
|
children =
|
|
|
|
[{xmlcdata, <<"An implementation of ">>},
|
|
|
|
#xmlel{name = <<"a">>,
|
|
|
|
attrs =
|
|
|
|
[{<<"href">>,
|
|
|
|
<<"http://tools.ietf.org/html/rfc6455">>}],
|
|
|
|
children =
|
|
|
|
[{xmlcdata,
|
|
|
|
<<"WebSocket protocol">>}]}]},
|
|
|
|
#xmlel{name = <<"p">>, attrs = [],
|
|
|
|
children =
|
|
|
|
[{xmlcdata,
|
|
|
|
<<"This web page is only informative. To "
|
|
|
|
"use WebSocket connection you need a Jabber/XMPP "
|
|
|
|
"client that supports it.">>}]}]}]}.
|
|
|
|
|
|
|
|
|
|
|
|
parse(#state{rfc_compilant = C} = State, Data) ->
|
|
|
|
case C of
|
|
|
|
undefined ->
|
2016-02-03 19:03:17 +01:00
|
|
|
P = fxml_stream:new(self()),
|
|
|
|
P2 = fxml_stream:parse(P, Data),
|
|
|
|
fxml_stream:close(P2),
|
2015-02-25 10:42:59 +01:00
|
|
|
case parsed_items([]) of
|
|
|
|
error ->
|
|
|
|
{State#state{rfc_compilant = true}, <<"parse error">>};
|
|
|
|
[] ->
|
|
|
|
{State#state{rfc_compilant = true}, <<"parse error">>};
|
|
|
|
[{xmlstreamstart, <<"open">>, _} | _] ->
|
|
|
|
parse(State#state{rfc_compilant = true}, Data);
|
|
|
|
_ ->
|
|
|
|
parse(State#state{rfc_compilant = false}, Data)
|
|
|
|
end;
|
|
|
|
true ->
|
2016-02-03 19:03:17 +01:00
|
|
|
El = fxml_stream:parse_element(Data),
|
2015-02-25 10:42:59 +01:00
|
|
|
case El of
|
|
|
|
#xmlel{name = <<"open">>, attrs = Attrs} ->
|
|
|
|
Attrs2 = [{<<"xmlns:stream">>, ?NS_STREAM}, {<<"xmlns">>, <<"jabber:client">>} |
|
|
|
|
lists:keydelete(<<"xmlns">>, 1, lists:keydelete(<<"xmlns:stream">>, 1, Attrs))],
|
|
|
|
{State, [{xmlstreamstart, <<"stream:stream">>, Attrs2}]};
|
|
|
|
#xmlel{name = <<"close">>} ->
|
|
|
|
{State, [{xmlstreamend, <<"stream:stream">>}]};
|
|
|
|
{error, _} ->
|
|
|
|
{State, <<"parse error">>};
|
|
|
|
_ ->
|
|
|
|
{State, [El]}
|
|
|
|
end;
|
|
|
|
false ->
|
|
|
|
{State, Data}
|
|
|
|
end.
|
|
|
|
|
|
|
|
parsed_items(List) ->
|
|
|
|
receive
|
|
|
|
{'$gen_event', El}
|
|
|
|
when element(1, El) == xmlel;
|
|
|
|
element(1, El) == xmlstreamstart;
|
|
|
|
element(1, El) == xmlstreamelement;
|
|
|
|
element(1, El) == xmlstreamend ->
|
|
|
|
parsed_items([El | List]);
|
|
|
|
{'$gen_event', {xmlstreamerror, _}} ->
|
|
|
|
error
|
|
|
|
after 0 ->
|
|
|
|
lists:reverse(List)
|
|
|
|
end.
|
2015-06-01 14:38:27 +02:00
|
|
|
|
|
|
|
opt_type(websocket_ping_interval) ->
|
|
|
|
fun (I) when is_integer(I), I >= 0 -> I end;
|
|
|
|
opt_type(websocket_timeout) ->
|
|
|
|
fun (I) when is_integer(I), I > 0 -> I end;
|
|
|
|
opt_type(_) ->
|
|
|
|
[websocket_ping_interval, websocket_timeout].
|