ejabberd - Comments for "http-bind send packet on timeout" https://www.ejabberd.im/node/4767 en --- https://www.ejabberd.im/node/4767#comment-57503 <pre>--- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -1475,6 +1475,7 @@ terminate(_Reason, StateName, StateData) -&gt; StateData#state.server, StateData#state.resource, ""), + announce_online(From#jid.lserver), presence_broadcast( StateData, From, StateData#state.pres_a, Packet), presence_broadcast( @@ -1488,6 +1489,22 @@ terminate(_Reason, StateName, StateData) -&gt; (StateData#state.sockmod):close(StateData#state.socket), ok. +%% Copied from mod_announce.erl +announce_online(Host) -&gt; + Packet = {xmlelement, "message", + [{"type", "chat"}], + [{xmlelement, "body", [], + [{xmlcdata, "Message stanza: Replaced by new connection"}]}]}, + announce_online1(ejabberd_sm:get_vh_session_list(Host), Host, Packet). + +announce_online1(Sessions, Server, Packet) -&gt; + Local = jlib:make_jid("", Server, ""), + lists:foreach( + fun({U, S, R}) -&gt; + Dest = jlib:make_jid(U, S, R), + ejabberd_router:route(Local, Dest, Packet) + end, Sessions). + %%%---------------------------------------------------------------------- %%% Internal functions %%%---------------------------------------------------------------------- </pre> Wed, 15 Jun 2011 11:18:45 +0000 mfoss comment 57503 at https://www.ejabberd.im Thanks, it works but not at https://www.ejabberd.im/node/4767#comment-57500 <p>Thanks, it works but not at all.<br /> Message is not sent to my interlocutors but to me :) When I connect after disconnect, I receive it, and the second thing I forget to tell, I want to sent this message to ALL people, even I haven't them on my roster.</p> Wed, 15 Jun 2011 10:17:08 +0000 rysi3k comment 57500 at https://www.ejabberd.im rysi3k wrote: I want to: 1. https://www.ejabberd.im/node/4767#comment-57489 <div class="quote-msg"> <div class="quote-author"><em>rysi3k</em> wrote:</div> <p>I want to:<br /> 1. send packet<br /> 2. to all my interlocutors<br /> 3. with information<br /> 4. when my session on http-bind will timeout. </p></div> <p>This patch satisfies 1 and 2, I don't know if it satisfies 3. The main problem is 4, the packet is sent for all cases of session close, not only with BOSH timeouts.</p> <pre> --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -1475,6 +1475,12 @@ terminate(_Reason, StateName, StateData) -&gt; StateData#state.server, StateData#state.resource, ""), + MsgPacket = {xmlelement, "message", + [{"type", "chat"}], + [{xmlelement, "body", [], + [{xmlcdata, "Message stanza: Replaced by new connection"}]}]}, + presence_broadcast( + StateData, From, StateData#state.pres_a, MsgPacket), presence_broadcast( StateData, From, StateData#state.pres_a, Packet), presence_broadcast( </pre> Tue, 14 Jun 2011 10:56:00 +0000 mfoss comment 57489 at https://www.ejabberd.im