Nearby Messages repeated on reconnecting

怎甘沉沦 提交于 2019-12-13 21:18:13

问题


I've written a small test application which works as a simple chat room using Nearby.MESSAGES_API.

When I subscribe I find that I receive a number of older Messages in my MessageListener (in onFound). If I disconnect and then reconnect (eg. switch to another application) I find that all the messages come through again. Is this meant to happen?

I have changed the application to include UUIDs in my messages and keep a stash of them to check whether I have received the message, but that may not be a good idea from a memory point of view (although I could put them in a database).

I don't understand how the "session" side of Nearby Messages works.


回答1:


In Google Play Services 7.8 the "sessions" are internally divided into ten minute buckets. You're not the first person to be confused by this, we're looking at options to do this differently in the future. No promises, but we recognize it's an issue.

(I work on the Nearby API)




回答2:


The issue was that publishAndSubscribe is called when onConnected is called. The issue with this is that onStart attempts to reconnect so publishAndSubscribe needn't be called again.



来源:https://stackoverflow.com/questions/32300786/nearby-messages-repeated-on-reconnecting

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