Latest packet handling, parsing, enums, generators, etc..

This commit is contained in:
Casper Warden
2017-11-24 17:45:34 +00:00
parent ec300e33ac
commit 261f28698a
496 changed files with 30448 additions and 57 deletions

View File

@@ -22,4 +22,40 @@ export class EnableSimulatorPacket implements Packet
return 14;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
buf.writeInt32LE(this.SimulatorInfo['Handle'].low, pos);
pos += 4;
buf.writeInt32LE(this.SimulatorInfo['Handle'].high, pos);
pos += 4;
this.SimulatorInfo['IP'].writeToBuffer(buf, pos);
pos += 4;
buf.writeUInt16LE(this.SimulatorInfo['Port'], pos);
pos += 2;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjSimulatorInfo: {
Handle: Long,
IP: IPAddress,
Port: number
} = {
Handle: Long.ZERO,
IP: IPAddress.zero(),
Port: 0
};
newObjSimulatorInfo['Handle'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
pos += 8;
newObjSimulatorInfo['IP'] = new IPAddress(buf, pos);
pos += 4;
newObjSimulatorInfo['Port'] = buf.readUInt16LE(pos);
pos += 2;
this.SimulatorInfo = newObjSimulatorInfo;
return pos - startPos;
}
}