I have an ejabberd server at jabber.domain.com, with an xmpp component written in python (using sleekxmpp) at presence.domain.com.
I wanted the component to get a notification each time a client changed his presence from available to unavailable and vice-versa.
The clients themselves don’t have any contacts.
Currently, I have set up my clients to send their available presence stanzas to admin@presence.domain.com, and I do get their online/offline presence notifications. But I feel this isn’t the right approach.
I was hoping the clients wouldn’t be aware of the component at presence.domain.com, and they would just connect to jabber.domain.com and the component should somehow get notified by the server about the clients presence.
Is there a way to do that?
Is my component setup correct? or should I think about using an xmpp plugin/module/etc..
Thanks
It is not difficult to write a custom ejabberd module for this. It will need to register to presence change hooks in ejabberd, and on each presence packet route a notification towards your external component.
There is a pair of hooks ‘set_presence_hook’ and ‘unset_presence_hook’ that your module can register to, to be informed when the users starts/end a session.
If you need to track other presence statuses, there is also a hook ‘c2s_update_presence’ that fires on any presence packets sent by your users.
Other possibility, without using a custom module, is using shared rosters. Add admin@presence.domain.com to the shared rosters of all your users, but in this case they will see this item reflected on their roster.