Where to create a MQTT/Socket connection in android?

55 views Asked by At

I am working on an app which receives realtime updates from the server and which will be using MQTT or Socket connection(TBD) to receive the realtime updates from the server. This manager will be responsible for receiving all the realtime updates across the app and delegate it to the respective viewmodel or fragment.

Couple of questions here:

1- Should I be running this Socket/MQTT connection manager as a service or it should be something else?

2- What's the best way of handling the realtime response by multiple surfaces of the app. Should I add in the instance of my fragment/activity/viewmodel to the list of listeners created as part of the connection manager. Or is there a better way to handle this?

0

There are 0 answers