Detect presence before sending?

Very new to ejabberd module development, really just looking for some direction here. I'm trying to develop a module that will intercept messages bound for a certain JID (user@domain), and forward it to a specific JID + resource (taken from a defined/fixed pool of resources) but I need to know if the selected resource is online or not. The messages need to go to an online user, offline message queuing is not an option for my particular scenario. Is something like this possible? Are there any examples out there on how this could be accomplished? What API(s) would I need to work with?

Answer:

Gonna answer my own question:

ejabberd_sm:get_user_resources(User, Server)

Returns a list of resources if the user is logged in, and an empty list if they're not logged in.

Syndicate content