1
votes

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 [email protected], 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

2
As far as I know, sleekxmpp is a synchronous/blocking library that will block the communication until it finishes current task processing, this means when the next message comes to your ejabberd and forwarded to your sleekxmpp, it will have to wait till it finishes, consequently, slowing the overall performance that you used ejabberd for .. how did you get around this?securecurve
I ditched the sleekxmpp component configuration and set up the ejabberd module that @ppolv described in his answer. Now the xmpp server sends a message to an external service whenever a client connects/ disconnects. The external service keeps track of the client's presence.Doody P

2 Answers

5
votes

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 [email protected] to the shared rosters of all your users, but in this case they will see this item reflected on their roster.

0
votes

It is possible for a component to subscribe to a user's presence exactly the same way a user does. Also it is possible for the user to subscribe to a component's presence. You just have to follow the usual pattern, i.e. the component/user sends a <presence/> of type subscribe which the user/component can accept by sending a <presence/> of type subscribed.

You can also have the user just send a presence to the component directly.

There is no need to write custom hooks or create proxy users.