简体   繁体   English

XMPP注销(Smack API)而无需与服务器断开连接

[英]XMPP Logout (Smack API) without disconnecting with the server

I am using smack API to connect to Openfire server. 我正在使用smack API连接到Openfire服务器。 Am able to create user, login and exchange message. 能够创建用户,登录和交换消息。 After logout I want my activity to be finished( user has to come to home screen) without disconnecting with the server. 注销后,我希望我的活动完成(用户必须进入主屏幕)而不断开与服务器的连接。
Any one have used Smack API for this kind of scenario? 在这种情况下,有人使用过Smack API吗?

If you are using smack on Android then you should consider running the connectivity part of your application as a service which can be flexible and run in the background. 如果您在Android上使用smack,则应考虑将应用程序的连接性部分作为一项服务运行,该服务可以灵活运行并在后台运行。 You will be disconnected from the server if your activity goes to the onStop() or onDestroy() state. 如果您的活动进入onStop()或onDestroy()状态,您将与服务器断开连接。

Logging out can be done by YourConnection.disconnect. 注销可以通过YourConnection.disconnect完成。 If you don't want to disconnect from the server you will have to change your presence instead. 如果您不想断开与服务器的连接,则必须更改您的状态。

I not found any solutions in the Smack documentation. 我在Smack文档中找不到任何解决方案。 If you make connect(), after disconnect() you will be authinticated again, and login throw AlreadyAuthanticated exception. 如果创建connect(),则在connect()之后,将再次进行身份验证,并登录抛出AlreadyAuthanticated异常。

But, after disconnect, you can destroy XMPPConnection obect and create new one . 但是,断开连接后, 您可以销毁XMPPConnection obect并创建一个新的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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