Android - Sockets vs Polling

前端 未结 3 402
暗喜
暗喜 2021-01-13 04:29

As part of an Android app I\'m developing there is a chat room feature. We have a server which can process the incoming messages and store the messages. Is it better to keep

相关标签:
3条回答
  • 2021-01-13 04:52

    It is bad solution with poll for app that have randomly posting data. What I want to say is that polling data is useful when you have something that is happening discrete like every 5 minutes or something like that. this is not the case with chat, some user can post something ones in a hour , some can post 30 times in 2 minutes

    so keep your sockets open

    0 讨论(0)
  • 2021-01-13 04:58

    I would keep the socket open if you are worried about instant messaging, it takes time to setup the socket connection especially if you are using the GSM connection. I have seen it take 10 secs or more to open up a socket on 3G, much less if on WiFi.

    0 讨论(0)
  • 2021-01-13 04:59

    Polling lacks real-time connection and a persistant connection is battery draining. I think that what you are looking for is a combination of "push"-ing and persistant connection. You would wake your phone via push, and then establish a connection via sockets to handle chat.

    I suggest reading this article. I'm not sure if it mentions c2dm, the google push service.

    0 讨论(0)
提交回复
热议问题