XMPP: count of unread messages

二次信任 提交于 2019-12-25 04:16:03

问题


I'm trying to implement chat for my webapp with following features:

  • When user logs in he should see a number of unread messages (which is both offline messages and "unseen", I will explain "unseen" in next step).
  • When user is anywhere in the app but on chat window he should be notified that he has a new message. Message should be marked "unseen" and must be added to the count of unread messages.

The first point is quite easily achieved using XEP-0013: Flexible Offline Message Retrieval. So I can retrieve offline messages and when I'm sure user has seen them - I remove them from unread list. But the problem is: how do I achieve same thing for "unseen" messages?

In short what I need is: any message should be marked as offline, unless user sees it and it's removed from the list by explicit request.

Can I achieve that with XMPP and how do I do that?

Thanks in advance.


回答1:


What you are trying to do is to basically store a counter of unseen stuff in your account. I think you do not need flexible offline retrieval as when you connect the messages would simply become unseen. You thus only have to deal with one case: Unseen.

I will reply from the perspective of ejabberd, that I know better as one of the developer: I would use private storage to store your current state of unseen count and conversation.



来源:https://stackoverflow.com/questions/30437866/xmpp-count-of-unread-messages

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