Here is the idea I have for a basic, skeleton server, part of which was taken from socket.io that might be filled in in the authoring tool, and default stuff may be added for physics (which is almost beyond my charter). I’m not sure of the license of socket.io. Can socket.io be used in PlayCanvas, or will we have to roll our own?
var app = require(‘express’)();
var http = require(‘http’).Server(app);
var io = require(‘socket.io’)(http);
app.get(’/’, function(req, res){
res.sendfile(‘index.html’);
});
function Multiplayer() {
};
Multiplayer.prototype = {
clientmessage: function(msg) { io.emit(‘servermessage’, msg); },
clientmove: function() {},
clientshoot: function() {},
clientslash: function() {},
clientpowerplay: function() {},
clientcounter: function() {},
clientquit: function() {},
clientturnbegin: function() {},
clientturnend: function() {},
};
io.on(‘connection’, function(socket){
socket.on(‘clientmessage’, Multiplayer.prototype[‘clientmessage’]);
socket.on(‘clientmove’, Multiplayer.prototype[‘clientmove’]);
socket.on(‘clientshoot’, Multiplayer.prototype[‘clientshoot’]);
socket.on(‘clientslash’, Multiplayer.prototype[‘clientslash’]);
socket.on(‘clientpowerplay’, Multiplayer.prototype[‘clientpowerplay’]);
socket.on(‘clientcounter’, Multiplayer.prototype[‘clientcounter’]);
socket.on(‘clientquit’, Multiplayer.prototype[‘clientquit’]);
socket.on(‘clientturnbegin’, Multiplayer.prototype[‘clientturnbegin’]);
socket.on(‘clientturnend’, Multiplayer.prototype[‘clientturnend’]);
});
http.listen(3000, function(){
console.log(‘listening on *:3000’);
});