Use a model for handling server-side events and develop a multiplayer game.


CanvasEngine implements a multiplayer game using NodeJS and

  1. Install Node.js and NPM

  2. Open the Shell :

    npm install canvasengine
  3. Create a. Js file in your project for the server

Here is an example of a client code :

<!DOCTYPE html>
<script src="canvasengine-X.Y.Z.all.min.js"></script>
<script src="extends/Socket.js"></script>

    var Model = io.connect('');

    var canvas = CE.defines("canvas").
        ready(function() {"MyScene");
      name: "MyScene",
      model: Model,
      events: ["load"], 
      ready: function(stage) {
      load: function(text) {

    <canvas id="canvas" width="675px" height="506px"></canvas>

And server code :

var CE = require("canvasengine").listen(8333);
CE.Model.init("Main", ["start"], {

  initialize: function() {

  start: function() {
    this.scene.emit("load", "Hello");

  1. The client sends data to the server with the emit method model property
  2. The method defined in the array is performed (method name sent by the client)
  3. Conversely, data is sent to the scene with the emit method scene property
  4. Here, the load method is executed and defined in the events property

The methods are the same as