Maybe someone has examples of code? I can't find anything about it. Jabber server - ejabberd.
As a client, you know a contact is online when: - he authorized your account to see his presence, - AND you receive his presence in your client.
Consequence: You have to track the presence of your contact on the client-side.