Hi,
I want to send packet to all my interlocutors with information when my session on http-bind will timeout.
It can be anything i must be able to receive it on other client-side.
It is possible?
I'm trying to edit http-bind module, but can't find anything which help me to send packet.
Best Regards.
rysi3k wrote: I want to: 1.
I want to:
1. send packet
2. to all my interlocutors
3. with information
4. when my session on http-bind will timeout.
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.
--- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -1475,6 +1475,12 @@ terminate(_Reason, StateName, StateData) -> 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(Thanks, it works but not at
Thanks, it works but not at all.
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.
---
--- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -1475,6 +1475,7 @@ terminate(_Reason, StateName, StateData) -> 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) -> (StateData#state.sockmod):close(StateData#state.socket), ok. +%% Copied from mod_announce.erl +announce_online(Host) -> + 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) -> + Local = jlib:make_jid("", Server, ""), + lists:foreach( + fun({U, S, R}) -> + Dest = jlib:make_jid(U, S, R), + ejabberd_router:route(Local, Dest, Packet) + end, Sessions). + %%%---------------------------------------------------------------------- %%% Internal functions %%%----------------------------------------------------------------------