var parts = encodedMessage.split(":"); var command = parts[1]; encodedMessage = parts[2] || ""; var config = null; if(command == "init"){ var configParts = encodedMessage.split("&"); config = {}; for(var i = 0; i < configParts.length; i++){ var nameValue = configParts[i].split("="); config[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]); } } return {command: command, message: encodedMessage, config: config};