extended file serving to static folder

This commit is contained in:
logsol 2012-07-07 18:53:44 +02:00
parent 5a7234ade4
commit 980af70259
4 changed files with 107 additions and 16 deletions

View file

@ -2,7 +2,50 @@ requirejs.config({
baseUrl: 'lib'
});
var Chuck;
requirejs(["Chuck/Chuck"], function(c) {
Chuck = c;
setupSocket();
});
requirejs(["Chuck/Chuck"], function(Chuck) {
function setupSocket(){
var socket = io.connect(location.href);
socket.on('connect', onConnect);
socket.on('message', onMessage);
socket.on('disconnect',onDisconnect);
}
function onConnect () {
console.log('Client connected');
Chuck.init();
});
}
function onMessage (packet) {
packet = JSON.parse(packet);
if (packet && packet.m) {
processServerCommand(packet);
}
}
function onDisconnect () {
console.log('client disconnected');
}
function processServerCommand(packet){
switch(packet.m) {
case 'join':
break;
case 'nick':
break;
case 'gameCommand':
Chuck.processGameCommand(packet.d);
break;
default:
break;
}
}