Keep the connection alive in openfire but show user as offline in xmpp

泄露秘密 提交于 2020-01-17 12:27:26

问题


I am developing an android chat application using openfire smack library.I have created a bound service to listen to messages when the is in background.The connection object is also maintained by service.Service is working fine as listening to background messages,but the problem is user is shown online all the time when the app is in background.Keeping the connection is also necessary so that user can listen to messages but this connection is showing user online all the time.I want to show user offline when app is in background.One thing more i am a beginner in android application as well as in xmpp protocol.If you think my question senseless plz don't vote down it because for a beginner every question has sense


回答1:


To show that user is offline, you need to send presence as unavailable to server so that it is published to your roster entries. Now you should be shown as offline to other users but your session exists so Openfire will route your messages to you. Now on application coming to foreground, you can send again your presence indicating you are available.



来源:https://stackoverflow.com/questions/39994438/keep-the-connection-alive-in-openfire-but-show-user-as-offline-in-xmpp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!