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

@@ -38,4 +38,78 @@ export class GroupNoticesListReplyPacket implements Packet
return size;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.AgentData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
this.AgentData['GroupID'].writeToBuffer(buf, pos);
pos += 16;
const count = this.Data.length;
buf.writeUInt8(this.Data.length, pos++);
for (let i = 0; i < count; i++)
{
this.Data[i]['NoticeID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt32LE(this.Data[i]['Timestamp'], pos);
pos += 4;
buf.write(this.Data[i]['FromName'], pos);
pos += this.Data[i]['FromName'].length;
buf.write(this.Data[i]['Subject'], pos);
pos += this.Data[i]['Subject'].length;
buf.writeUInt8((this.Data[i]['HasAttachment']) ? 1 : 0, pos++);
buf.writeUInt8(this.Data[i]['AssetType'], pos++);
}
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjAgentData: {
AgentID: UUID,
GroupID: UUID
} = {
AgentID: UUID.zero(),
GroupID: UUID.zero()
};
newObjAgentData['AgentID'] = new UUID(buf, pos);
pos += 16;
newObjAgentData['GroupID'] = new UUID(buf, pos);
pos += 16;
this.AgentData = newObjAgentData;
const count = buf.readUInt8(pos++);
this.Data = [];
for (let i = 0; i < count; i++)
{
const newObjData: {
NoticeID: UUID,
Timestamp: number,
FromName: string,
Subject: string,
HasAttachment: boolean,
AssetType: number
} = {
NoticeID: UUID.zero(),
Timestamp: 0,
FromName: '',
Subject: '',
HasAttachment: false,
AssetType: 0
};
newObjData['NoticeID'] = new UUID(buf, pos);
pos += 16;
newObjData['Timestamp'] = buf.readUInt32LE(pos);
pos += 4;
newObjData['FromName'] = buf.toString('utf8', pos, length);
pos += length;
newObjData['Subject'] = buf.toString('utf8', pos, length);
pos += length;
newObjData['HasAttachment'] = (buf.readUInt8(pos++) === 1);
newObjData['AssetType'] = buf.readUInt8(pos++);
this.Data.push(newObjData);
}
return pos - startPos;
}
}