简体   繁体   中英

Change status of an XMPP user in Django using ejabberd

I want a Functionality where If a user change his status, that status needs to reflect at runtime (like Whatsapp). My App is in IOS and Android and backend is in Django.

I am advised to use ejabberd server for this as tt supports XMPP protocol. I am not sure how to implement this functionality. Can anyone guide me?

There is many ways in XMPP to express the state of the user:

  • presence : It allows you to convey both the availability of the user (among predefined "show" elements : Available, Away, Do not Disturb, etc) and your status (Free form text). However, presence is related to the user session and suppose he has an XMPP session open (and thus is connected). It means it is intended to be set by user from client, not from backend and is only broadcast to contacts when the user is online.

  • Last activity : This is something that complement XMPP presence. It is a way to get user state information when the user is offline. I would recommend to use that to get more familiar with XMPP. To integrate with your back-end, I would setup ejabberd to store last activity in database and to update it in database from your backend. User that need to read it (For example when a conversion tab is opened) can display the XMPP if the user is online, or the last activity if the user if offline. You can also just let the user set its own status on last presence when getting unavailable (offline). It will be automatically updated in the last table by ejabberd.

  • mood : This is something used to express state in a more complete way. User can set mood with more richer status and the mood is not tight to presence. However, it is a bit more complex to integrate with backend as it is based on the PubSub protocol.

To summarize, in your case, you can use a mix of standard XMPP presence and Last activity with change of status from backend.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM