mirror of
https://github.com/processone/ejabberd
synced 2025-10-06 03:50:15 +02:00
Use new API for IQ routing
Functions ejabberd_local:route_iq/2,3 are now depecated: ejabberd_router:route_iq/2,3,4 should be used instead.
This commit is contained in:
parent
66c9f6458d
commit
7a3092a859
9 changed files with 331 additions and 271 deletions
|
@ -132,7 +132,7 @@ handle_cast({start_ping, JID}, State) ->
|
|||
handle_cast({stop_ping, JID}, State) ->
|
||||
Timers = del_timer(JID, State#state.timers),
|
||||
{noreply, State#state{timers = Timers}};
|
||||
handle_cast({iq_pong, JID, timeout}, State) ->
|
||||
handle_cast({iq_reply, timeout, JID}, State) ->
|
||||
Timers = del_timer(JID, State#state.timers),
|
||||
ejabberd_hooks:run(user_ping_timeout, State#state.host,
|
||||
[JID]),
|
||||
|
@ -149,20 +149,19 @@ handle_cast({iq_pong, JID, timeout}, State) ->
|
|||
_ -> ok
|
||||
end,
|
||||
{noreply, State#state{timers = Timers}};
|
||||
handle_cast({iq_pong, _JID, _}, State) ->
|
||||
handle_cast({iq_reply, #iq{}, _JID}, State) ->
|
||||
{noreply, State};
|
||||
handle_cast(Msg, State) ->
|
||||
?WARNING_MSG("unexpected cast: ~p", [Msg]),
|
||||
{noreply, State}.
|
||||
|
||||
handle_info({timeout, _TRef, {ping, JID}}, State) ->
|
||||
From = jid:make(State#state.host),
|
||||
Host = State#state.host,
|
||||
From = jid:remove_resource(JID),
|
||||
IQ = #iq{from = From, to = JID, type = get, sub_els = [#ping{}]},
|
||||
Pid = self(),
|
||||
F = fun (Response) ->
|
||||
gen_server:cast(Pid, {iq_pong, JID, Response})
|
||||
end,
|
||||
ejabberd_local:route_iq(IQ, F, State#state.ping_ack_timeout),
|
||||
ejabberd_router:route_iq(IQ, JID,
|
||||
gen_mod:get_module_proc(Host, ?MODULE),
|
||||
State#state.ping_ack_timeout),
|
||||
Timers = add_timer(JID, State#state.ping_interval,
|
||||
State#state.timers),
|
||||
{noreply, State#state{timers = Timers}};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue