Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -22,4 +22,44 @@ export class InternalScriptMailPacket implements Packet
|
||||
return (this.DataBlock['From'].length + 1 + this.DataBlock['Subject'].length + 1 + this.DataBlock['Body'].length + 2) + 16;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
buf.write(this.DataBlock['From'], pos);
|
||||
pos += this.DataBlock['From'].length;
|
||||
this.DataBlock['To'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.write(this.DataBlock['Subject'], pos);
|
||||
pos += this.DataBlock['Subject'].length;
|
||||
buf.write(this.DataBlock['Body'], pos);
|
||||
pos += this.DataBlock['Body'].length;
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjDataBlock: {
|
||||
From: string,
|
||||
To: UUID,
|
||||
Subject: string,
|
||||
Body: string
|
||||
} = {
|
||||
From: '',
|
||||
To: UUID.zero(),
|
||||
Subject: '',
|
||||
Body: ''
|
||||
};
|
||||
newObjDataBlock['From'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjDataBlock['To'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjDataBlock['Subject'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjDataBlock['Body'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
this.DataBlock = newObjDataBlock;
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user