Smack - When to call MultiUserChat.Join(…)

社会主义新天地 提交于 2019-12-12 01:47:01

问题


I'm a bit confused and can't find the answer in the docs. I'm developing a simple chat app for Android. I've created a group (muc) and everything works, but do I have to keep calling join() everytime I open the app?

I've noticed that it doesn't work otherwise.. Don't understand why since the server knows that my jabberID is connected to this muc.

Hope my question is clear enough. Thanks.


回答1:


A (I Hope) complete explanation: short answer is yes.

When a persistent room is created on your server, and you logout or exit the room, you have to re-join each time. A logout or connection lose is obvious, but when you exit (leave) the room, you also won't receive messages directly from it (even though your still connected to the server), the server knows your id is affiliated with that MUC (as a member for example), but you're not inside it, for further info refer to the XEP about MUC, and also read about how your specific server implements it on your server docs (probably saves messages under a room-to-offline users, or something similar).

That is basically what happens in WhatsApp when you go in and out of group chats, but they also have their own custom way (the layer they built on top of the basic xmpp server) to let you know about unread messages, that includes both a service (you can see it in your phone in the general settings->apps) and push notifications.




回答2:


  1. Create Service
  2. Add your xmpp code in it, like login, one to one chat, MUC chat.

So even your app closed service will remain in background and you will be always connected to chatrooms.



来源:https://stackoverflow.com/questions/30702999/smack-when-to-call-multiuserchat-join

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