delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

Improve attempts to re-connect by listening for connectivity changes #98

Open ocram opened 8 years ago

ocram commented 8 years ago

When the device loses its internet connection, we do currently queue the messages that cannot be send. The library will then try to re-connect several times. If it fails every time, the library will just stop trying and disconnect. If connection can be re-established, the queued messages are dispatched.

We could enhance the process of trying to re-connect by listening for connectivity changes. This could be more efficient. The required permission <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> will not always be there, but when it is, we can use a broadcast receiver for <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />.

rakirox commented 8 years ago

I'll to do it my self. Hope it works 👍

My fast solution it's to aim the broadcast with the singletonMeteor to control this event. Let me implement it.