mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
Merge pull request #300 from weiss/resend-if-offline
XEP-0198: Support "resend_on_timeout: if_offline"
This commit is contained in:
commit
c18413c52b
@ -1022,7 +1022,7 @@ request_handlers:
|
|||||||
/"a"/"b": mod_foo
|
/"a"/"b": mod_foo
|
||||||
/"http-bind": mod_http_bind
|
/"http-bind": mod_http_bind
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
\titem{resend\_on\_timeout: true|false}
|
\titem{resend\_on\_timeout: true|false|if\_offline}
|
||||||
If \term{stream\_management} is enabled and this option is set to
|
If \term{stream\_management} is enabled and this option is set to
|
||||||
\term{true}, any stanzas that weren't acknowledged by the client
|
\term{true}, any stanzas that weren't acknowledged by the client
|
||||||
will be resent on session timeout. This behavior might often be
|
will be resent on session timeout. This behavior might often be
|
||||||
@ -1030,8 +1030,12 @@ request_handlers:
|
|||||||
circumstances. For example, a message that was sent to two resources
|
circumstances. For example, a message that was sent to two resources
|
||||||
might get resent to one of them if the other one timed out.
|
might get resent to one of them if the other one timed out.
|
||||||
Therefore, the default value for this option is \term{false}, which
|
Therefore, the default value for this option is \term{false}, which
|
||||||
tells ejabberd to generate an error message instead. The option can
|
tells ejabberd to generate an error message instead. As an
|
||||||
be specified for \term{ejabberd\_c2s} listeners.
|
alternative, the option may be set to \term{if\_offline}. In this
|
||||||
|
case, unacknowledged stanzas are resent only if no other resource is
|
||||||
|
online when the session times out. Otherwise, error messages are
|
||||||
|
generated. The option can be specified for \term{ejabberd\_c2s}
|
||||||
|
listeners.
|
||||||
\titem{resume\_timeout: Seconds}
|
\titem{resume\_timeout: Seconds}
|
||||||
This option configures the number of seconds until a session times
|
This option configures the number of seconds until a session times
|
||||||
out if the connection is lost. During this period of time, a client
|
out if the connection is lost. During this period of time, a client
|
||||||
|
@ -316,7 +316,11 @@ init([{SockMod, Socket}, Opts]) ->
|
|||||||
Timeout when is_integer(Timeout), Timeout >= 0 -> Timeout;
|
Timeout when is_integer(Timeout), Timeout >= 0 -> Timeout;
|
||||||
_ -> 300
|
_ -> 300
|
||||||
end,
|
end,
|
||||||
ResendOnTimeout = proplists:get_bool(resend_on_timeout, Opts),
|
ResendOnTimeout = case proplists:get_value(resend_on_timeout, Opts) of
|
||||||
|
Resend when is_boolean(Resend) -> Resend;
|
||||||
|
if_offline -> if_offline;
|
||||||
|
_ -> false
|
||||||
|
end,
|
||||||
IP = peerip(SockMod, Socket),
|
IP = peerip(SockMod, Socket),
|
||||||
Socket1 = if TLSEnabled andalso
|
Socket1 = if TLSEnabled andalso
|
||||||
SockMod /= ejabberd_frontend_socket ->
|
SockMod /= ejabberd_frontend_socket ->
|
||||||
@ -2879,7 +2883,15 @@ handle_unacked_stanzas(_StateData, _F) ->
|
|||||||
handle_unacked_stanzas(StateData)
|
handle_unacked_stanzas(StateData)
|
||||||
when StateData#state.mgmt_state == active;
|
when StateData#state.mgmt_state == active;
|
||||||
StateData#state.mgmt_state == pending ->
|
StateData#state.mgmt_state == pending ->
|
||||||
ReRoute = case StateData#state.mgmt_resend of
|
ResendOnTimeout =
|
||||||
|
case StateData#state.mgmt_resend of
|
||||||
|
Resend when is_boolean(Resend) ->
|
||||||
|
Resend;
|
||||||
|
if_offline ->
|
||||||
|
ejabberd_sm:get_user_resources(StateData#state.user,
|
||||||
|
StateData#state.server) == []
|
||||||
|
end,
|
||||||
|
ReRoute = case ResendOnTimeout of
|
||||||
true ->
|
true ->
|
||||||
fun ejabberd_router:route/3;
|
fun ejabberd_router:route/3;
|
||||||
false ->
|
false ->
|
||||||
|
Loading…
Reference in New Issue
Block a user