开发者

Smack: Is it necessary (or even possible) to explicity close a Chat?

开发者 https://www.devze.com 2023-02-14 18:48 出处:网络
After开发者_如何学C opening an XMPP Chat using the Smack library, is it necessary (or even possible) to explicitly close a Chat?You simply drop your own references to it, and it will eventually disapp

After开发者_如何学C opening an XMPP Chat using the Smack library, is it necessary (or even possible) to explicitly close a Chat?


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.


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

<message 
    from='juliet@capulet.com/balcony'
    to='romeo@shakespeare.lit/orchard'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <gone xmlns='http://jabber.org/protocol/chatstates'/>
</message>


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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消