Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user