I am developing a game with offline capability (e.g. for mobile
devices). Communication is via Socket.IO, with [localStorage][1] as
offline cache for hiscores. Details (client = browser):
* On client load:
- hiscores are retrieved from localStorage,
- updated hiscores are requested from the server,
- unsaved hiscores are sent to server (for saving in database).
* On new hiscores on server: new saved hiscores are broadcasted to all
clients
* On new hiscore entry on client: unsaved hiscores are sent to server
This mostly works fine, for example in the following scenario:
1. Load game.
2. Stop server, for testing.
3. Play game, and submit new hiscores entry.
4. Some time later: start server
In step 4, the hiscores entry gets automatically sent to the server *if*
the server hasn't been offline for too long. At the moment I am using
default Socket.IO settings: Socket.IO tries reconnecting ten times over
a short period of time.
Now, how do I configure Socket.IO so that step 4 always works? Should I
just tell it to try reconnecting forever? What is the recommended way to
handle situations like this?
By the way, the app uses [application cache][2].
[1]:
http://www.w3.org/TR/webstorage/#the-localstorage-attribute
[2]:
http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#appcache