mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 05:35:56 -04:00
Reintroduce packetsToParse
This commit is contained in:
parent
64f24858dd
commit
f6a16bfdff
@ -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") {
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user