Smack:是否有必要(甚至可能)明确关闭聊天?

发布于 2024-10-20 06:09:14 字数 47 浏览 1 评论 0原文

使用 Smack 库打开 XMPP 聊天后,是否有必要(甚至可能)显式关闭聊天?

After opening an XMPP Chat using the Smack library, is it necessary (or even possible) to explicitly close a Chat?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

简单气质女生网名 2024-10-27 06:09:14

您只需删除自己对它的引用,它最终就会自行消失。它仅由 ChatManager 内的弱引用保存,因此最终会被 GC 回收。

如果您不想在 Chat 类等待 GC 时接收更多聊天消息,那么您也应该删除侦听器。

You simply drop your own references to it, and it will eventually disappear on it's own. It is only held by weak references inside the ChatManager so it will get GC'ed eventually.

You should probably remove your listeners as well though, if you don't want to receive any more chat messages while the Chat class is waiting to be GC'ed.

请你别敷衍 2024-10-27 06:09:14

就协议而言,您可以实施XEP-85(聊天状态通知)以让其他人对方知道你已经关闭了聊天。

<message 
    from='[email protected]/balcony'
    to='[email protected]/orchard'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <gone xmlns='http://jabber.org/protocol/chatstates'/>
</message>

Protocol-wise, you can implement XEP-85 (Chat State Notifications) to let the other side know that you have closed the chat.

<message 
    from='[email protected]/balcony'
    to='[email protected]/orchard'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <gone xmlns='http://jabber.org/protocol/chatstates'/>
</message>
沉默的熊 2024-10-27 06:09:14

如果您使用 SMACK API,则无需关闭聊天。当您注销或关闭连接时,它将自动关闭。

No not necessary to close chat if you are using SMACK API. When you log out or close connection it will be automatically closed.

通知家属抬走 2024-10-27 06:09:14

我有一个侧面板,显示所有打开的聊天。它允许用户删除任何打开的聊天记录。如果关闭连接,所有打开的聊天都会消失,而不仅仅是被删除的聊天。我也四处查看,似乎没有办法显式销毁聊天,因为垃圾收集可能需要很长时间才能收集对象。

I have a side panel that shows all the open chats. It allows the user to delete anyone of the open chats. If you close the connection, then all the open chats disappear and not just the one that is deleted. I poked around as well, doesn't seem like there's a way to explicitly destroy the chat as garbage collection may take a long time to collect the object.

绝影如岚 2024-10-27 06:09:14

请遵循此错误报告,因为目前无法关闭聊天。
但由于这个问题已经被报道并承认它可以在下一个版本中修复。

Please follow this bug report, because currently it's not possible to close a chat.
But since this had been reported and acknowledge it could be fixed in the next version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文