I'm tasked with the development of a general use multiplayer API in JavaScript, with a Node.js back-end. The goal of the API is to provide a service to JavaScript mobile game developers so they can develop multiplayer games with an easy to use API and existing back-end.
The project also includes the development of implementations, a Node.js server and a test game, otherwise I can't test it ofcourse. So it's more accurate to call it the development of an entire library.
The problem I'm having is trying to figure out how to provide a nice mechanism for game synchronization. The library can provide room- and connection-management, friendlists, registration and soforth because those things are using the same mechanism in every game. However, game synchronization logic can be very game-specific and that is absolutely not allowed in a general use library and server.
I'm using the following libraries/frameworks for development:
- Node.js as a game server.
- Socket.io on client- and server-side for websocket communication.
- Require.js client-side to enable modular development.
- Redis as a database for persistent storage.
To clarify the goal of the library:
- Support for a wide range of games, from a turn-based strategy game with 100 syncable objects to a multiplayer top-down shooter where latency is of the utmost importance.
- No client has to act as 'server' of some sort.
- Minimize manual setup client-side.
- Accurate synchronization without synchronizing the entire gamestate.
- Server-client architecture without the server containing game-specific code.
- Shouldn't pose restrictions to the developer and shouldn't demand certain coding practices.
- Provide an easy to use abstraction to use the generic synchronization mechanism.
- The whole range of games has to be supported by the same generic server logic.
- Lag compensation must be automatic in the API or on the server, but not game specific.
So for the main question: is this possible or should I just provide a way to easily cast, multicast and broadcast messages, and leave the actual synchronization mechanism to the developer? How would you go about it?