diff --git a/lib/connection.js b/lib/connection.js index 927ac6aa..550d1e20 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -13,6 +13,11 @@ module.exports = Connection; var nextConnectionId = 0; +// Mapping of packet types to handler function names (forward declaration, see +// definition below the Connection class). +// +var PACKET_HANDLERS; + // JSTP connection class // transport - an abstract socket // server - JSTP server instance, used only for server-side parts @@ -331,7 +336,7 @@ Connection.prototype._processPacket = function(packet) { return; } - var handler = Connection.PACKET_HANDLERS[kind]; + var handler = PACKET_HANDLERS[kind]; if (handler) { handler.call(this, packet, keys); } else { @@ -631,9 +636,7 @@ Connection.prototype._emitPacketEvent = function(kind, packet, packetId, args) { this.emit(kind, eventArgs); }; -// Mapping of packet types to handler function names -// -Connection.PACKET_HANDLERS = { +PACKET_HANDLERS = { handshake: Connection.prototype._processHandshakePacket, call: Connection.prototype._processCallPacket, callback: Connection.prototype._processCallbackPacket,