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,42 @@ export class ImagePacketPacket implements Packet
return (this.ImageData['Data'].length + 2) + 18;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.ImageID['ID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt16LE(this.ImageID['Packet'], pos);
pos += 2;
buf.write(this.ImageData['Data'], pos);
pos += this.ImageData['Data'].length;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjImageID: {
ID: UUID,
Packet: number
} = {
ID: UUID.zero(),
Packet: 0
};
newObjImageID['ID'] = new UUID(buf, pos);
pos += 16;
newObjImageID['Packet'] = buf.readUInt16LE(pos);
pos += 2;
this.ImageID = newObjImageID;
const newObjImageData: {
Data: string
} = {
Data: ''
};
newObjImageData['Data'] = buf.toString('utf8', pos, length);
pos += length;
this.ImageData = newObjImageData;
return pos - startPos;
}
}