mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
34 lines
No EOL
740 B
JavaScript
Executable file
34 lines
No EOL
740 B
JavaScript
Executable file
define([
|
|
"Game/Core/Protocol/Parser"
|
|
],
|
|
|
|
function (Parser) {
|
|
|
|
var Helper = {}
|
|
|
|
Helper.encodeCommand = function (command, options) {
|
|
return Parser.encode(Helper.assemble(command, options));
|
|
}
|
|
|
|
Helper.assemble = function (command, options) {
|
|
var commands = {};
|
|
commands[command] = options || null;
|
|
return commands;
|
|
}
|
|
|
|
Helper.runCommands = function (message, callback) {
|
|
var commands;
|
|
if (typeof message == "string") {
|
|
commands = Parser.decode(message);
|
|
} else {
|
|
commands = message;
|
|
}
|
|
|
|
for(var command in commands) {
|
|
callback(command, commands[command]);
|
|
}
|
|
}
|
|
|
|
return Helper;
|
|
|
|
}); |