Binlog.prototype.determinePacket = function(byte, parser) { /** * Peak into the buffer to locate the packet type. */ var type = parser._buffer[parser._offset + 5]; if(byte === 0x00) { /** * Check to see if we have a packet handler */ if(type in this._parsers){ console.log("Handling event: ", this._parsers[type].name); /** * Assign the meta data to the parser * @type {[type]} */ parser._checksums = this._checksums; /** * Add a reference to the table map to the parser * so each packet can access them. */ parser._maps = this._maps; /** * Return the Packet Class */ return this._parsers[type]; } } // Let the default handler handle it. return Sequences.Sequence.determinePacket(byte); };
/** * Binlog Sequence * @param {Object} options Binlog Options * @param {Function} callback When packet is decrypted */ function Binlog(options, callback) { if (!callback && typeof options === 'function') { callback = options; options = {}; } /** * Default options */ options = options || {}; /** * Call the super() */ Sequences.Sequence.call(this, callback); /** * Set the options locally. */ this._position = options.binlog_position || 4; this._server_id = options.server_id || 1; this._filename = options.binlog_file || ""; this._flags = options.non_blocking ? 1 : 0; this._checksums = options.checksum_enabled ? true : false; /** * Table map container, this is used by events to lookup * extra row data based on the tablerow event that was * received in a preveius packet */ this._maps = {}; /** * Fetch the parsers * @type {Object} */ this._parsers = options.parsers; }