I try to develop "Reservation" application. It means: When the user clicks "Reserve" button it adds to database as "+1" of total reservation. But when the same user click "Unreserve" it subtracts from database as "-1". But the problem is that it works properly only when the internet connection is turn on.
In the second case, when internet is turn off and user click "Reserve" it show "1" in database(after turn on the internet) -> it means it not add value to database but just replace with this "1".
So:
(Online)
Database: "9" -> click "Reserve" value is increasing "+1".
Database after "Reserve": "10"
Database after "Unreserve": "9".
When user try to reserve when the internet is turn off it looks like:
(Offline)
Database: "9" -> click "Reserve" value is replacing with "+1".
Database after turn on internet "Reserve": "1"
Database after "Unreserve": "-1"
To resolve this situation in properly way, should I set that "Buttons" work only when the internet connection is turn on? Is this the easiest way to resolve this problem?
I read about onDisconnect() method but I didn't see any case how to set the firebase to work only with the user is online without any
I would appreciate if someone could give me a tip what should I implement to work this with any troubles.