Reintroduce packetsToParse

This commit is contained in:
roblabla 2015-05-22 22:25:12 +00:00
parent 64f24858dd
commit f6a16bfdff
2 changed files with 4 additions and 3 deletions

View File

@ -23,6 +23,7 @@ function Client(isServer) {
EventEmitter.call(this);
var socket;
this.packetsToParse = {};
this.serializer = serializer.createSerializer({ isServer });
this.compressor = null;
@ -32,7 +33,7 @@ function Client(isServer) {
this.decipher = null;
this.splitter = framing.createSplitter();
this.decompressor = null;
this.deserializer = serializer.createDeserializer({ isServer });
this.deserializer = serializer.createDeserializer({ isServer, packetsToParse: this.packetsToParse });
this._state = states.HANDSHAKING;
Object.defineProperty(this, "state", {
@ -53,7 +54,6 @@ function Client(isServer) {
this.isServer = !!isServer;
this.packetsToParse = {};
this.on('newListener', function(event, listener) {
var direction = this.isServer ? 'toServer' : 'toClient';
if(protocol.packetStates[direction].hasOwnProperty(event) || event === "packet") {

View File

@ -30,10 +30,11 @@ class Serializer extends Transform {
}
class Deserializer extends Transform {
constructor({ state = protocol.states.HANDSHAKING, isServer = false } = {}) {
constructor({ state = protocol.states.HANDSHAKING, isServer = false, packetsToParse = {"packet": true} } = {}) {
super({ readableObjectMode: true });
this.protocolState = state;
this.isServer = isServer;
this.packetsToParse = packetsToParse;
}
_transform(chunk, enc, cb) {