Sending IQ Packets To Clients

I'm trying to initiate an IQ packet exchange from a module to a client. In other words, I'd like to be able to send get and set IQ packets to a client and receive result and error responses. I'm having problems figuring out how to do this with ejabberd 2.0.1.

I'm getting hung up in ejabber_sm:do_route/3. It detects the IQ packet and then appears to look for a registered IQ handler on the server. My clients will be written in a variety of languages, most commonly Ruby and Python, which means that the ets lookup ejabber_sm:process_iq/3 does to find the MFA (Module, Function, Args) registered as the IQ handler won't succeed which is why I'm getting "service unavailable" errors.

Is there a way to initiate an IQ packet exchange with a client from the server? I'm hoping I've missed something and this is actually possible.

You can see mod_vcard.erl,

I don't remember doing this exactly, so I'll just give some points. I hope some of them give you a good idea to solve the problem:

You can see mod_vcard.erl, it handles some IQ namespace:

   IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
    gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
				  ?MODULE, process_local_iq, IQDisc),
    gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_VCARD,
				  ?MODULE, process_sm_iq, IQDisc),

You can also look at mod_caps. That module performs many tasks, one of them: send an IQ query to discover features of remote Jabber servers; and when the response is received, parse it and store information.

Or you can implement a jabber component (like mod_echo, mod_vcard, mod_pubsub, mod_muc, ...), so you have your own JID (test.example.org or whatever), and you can do whatever you want with IQ :)

Syndicate content