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

@@ -23,4 +23,44 @@ export class SendXferPacketPacket implements Packet
return (this.DataPacket['Data'].length + 2) + 12;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
buf.writeInt32LE(this.XferID['ID'].low, pos);
pos += 4;
buf.writeInt32LE(this.XferID['ID'].high, pos);
pos += 4;
buf.writeUInt32LE(this.XferID['Packet'], pos);
pos += 4;
buf.write(this.DataPacket['Data'], pos);
pos += this.DataPacket['Data'].length;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjXferID: {
ID: Long,
Packet: number
} = {
ID: Long.ZERO,
Packet: 0
};
newObjXferID['ID'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
pos += 8;
newObjXferID['Packet'] = buf.readUInt32LE(pos);
pos += 4;
this.XferID = newObjXferID;
const newObjDataPacket: {
Data: string
} = {
Data: ''
};
newObjDataPacket['Data'] = buf.toString('utf8', pos, length);
pos += length;
this.DataPacket = newObjDataPacket;
return pos - startPos;
}
}