Velojet
No worries, I'm going to explore your code and aim to help you achieve this goal.
There's good and bad news around this:
For the non-technical - server software such has node.js has allowed developers to use the same code client and server side. This means that a method of generating code to be inserted server side can be dreamt of. This is what velojet is actually doing here. He's used code from the runtime that he could run on the server.
However, you need a server for multiplayer.
Latency and lag needs to be managed effectively with a few methods:
- The design of your data for the game
- The amount of players you want on any screen at one time
- Optimisation to be sent via binary means (this is your data broken down into its component parts with no 'bloat' added)
Your game needs to design against cheats:
- Only send a 'request to perform an action' to the server
- Client makes the move to avoid lag whilst waits for server
- Server works out where it expects the player should be/what status they are at etc when the message is receivied
- Client checks if the move is inline with the server when the response comes through and corrects it to the expectation if wildly different
This is prediction correction. en.wikipedia.org/wiki/Client-side_prediction
So, there's a few things here that make multi-player not so simple as a plugin. You need to be able to design your game in a way to be optimised for multi-player.
Cheaters especially need to be quelled if you want to do in-app purchasing developers.google.com/commerce/wallet/digital
I'm working on all this and like velojet, it's important to get an example working with the steps you take to even think about what elements are needed to give a true multiplayer plugin.