0
votes

I am using openfire for chat application in iOs and php website. and everything is working fine.

I have also implemented push notifications when opponent user is offline and you are sending a message to that user (in short push notification for offline message). I have implemented above stuff which is available here : Openfire offline notification through PHP

Now, client asks me to implement one more feature which includes :

  • Send mail to admin when any user goes offline.

But now there is no any hook available to track user status. So how to implement the same ?

What I tried

I also tried one trick in which I am sending broadcast message to all users and if any user is offile then my CallbackOnOffline plugin will invoke, but here its not sending broadcast message to offline users.

1

1 Answers

1
votes

You can give a try to "intercept" Presence packet with Presence.Type.unavailable

Openfire has a ConnectionCloseListener (in SessionManager class) that fires a Presence unavailable.

If you read the class comments, it says

  // Send an unavailable presence to the user's subscribers
  // Note: This gives us a chance to send an unavailable presence to the
  // entities that the user sent directed presences

so probably it's possible to have an administrative user who can auto-subscribe to all users, recive the presence-unavailable and so you'll be able to just intercept the packet direct to this user to send your e-mail.

With opposite logic you'll be able to force a direct presence to something you control and intercept presence-unavailable to this entity