mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Added communication structure
This commit is contained in:
parent
980af70259
commit
94f63fc7b2
10 changed files with 292 additions and 129 deletions
16
client.js
16
client.js
|
|
@ -21,11 +21,11 @@ function onConnect () {
|
|||
Chuck.init();
|
||||
}
|
||||
|
||||
function onMessage (packet) {
|
||||
packet = JSON.parse(packet);
|
||||
function onMessage (message) {
|
||||
var commands = JSON.parse(message);
|
||||
|
||||
if (packet && packet.m) {
|
||||
processServerCommand(packet);
|
||||
for(var command in commands) {
|
||||
processControlCommand(type, command[type]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -33,16 +33,16 @@ function onDisconnect () {
|
|||
console.log('client disconnected');
|
||||
}
|
||||
|
||||
function processServerCommand(packet){
|
||||
switch(packet.m) {
|
||||
case 'join':
|
||||
function processControlCommand(command, options){
|
||||
switch(command) {
|
||||
case 'joined':
|
||||
break;
|
||||
|
||||
case 'nick':
|
||||
break;
|
||||
|
||||
case 'gameCommand':
|
||||
Chuck.processGameCommand(packet.d);
|
||||
Chuck.processGameCommand(options);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue