https://kotlinlang.org logo
#android
Title
# android
g

gabrielfv

10/02/2017, 7:49 PM
I know this isn't exactly kotlin related, but I think you guys might have some good advice. I need to manage a pub-sub connection between an android device and a server. Ideally, that means the app would need to listen to the server. How would you manage that? Periodically raise a connection (the server keeps messages on a buffer and fire them as soon as there is a connection established)? The app needs to at least look real time (instantly fire messages sent from app, receive messages without much delaying).
stackoverflow 8
e

Edwin Ramirez Ventura

10/02/2017, 8:26 PM
Instead of keep listening to the server, you could use push notification to notify the Smartphone that there are new data available or sending the data directly
v

villela

10/02/2017, 8:29 PM
IMHO push notifications are not reliable, especially for something that needs to be real time
I would go for pooling/mqtt when the app is in foreground and rely on push notifications only when the app is not being used
👍 1
g

gabrielfv

10/02/2017, 8:46 PM
I think I'll stick to the MQTT continuosly open when on foreground. An open socket will not be as costly as pooling and won't waste as much bandwidth. Thanks