I am in the process of designing a chat application with cordova for android devices. I have been researching and have come to the conclusion that there are two ways to go about this that could work.
- Websockets. Using websockets the client application could send a message to a webserver, the webserver could lookup the ip address of the recipient within a database and send the message to the recipient. This will require much more logic on the server but will eliminate the need for constant polling. This method would also require a constant loop on the client that would detect network changes and send the updated ip address to the webserver so that the webserver would know where to send the message.
- Constant polling. Have client application constantly poll the web server for updates. This would be the easiest method as server logic would be limited. Also there would be no need for logic in the application to handle the case when users switch networks. However the common consensus is to stay away from designs that utilize constant polling as it is a massive drain on device battery life.
My question is then: Does the issue of battery life for constant polling warrant the extra logic/time to implement a solution with websockets?