Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -38,4 +38,74 @@ export class DirGroupsReplyPacket implements Packet
|
||||
return size;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
this.AgentData['AgentID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.QueryData['QueryID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
const count = this.QueryReplies.length;
|
||||
buf.writeUInt8(this.QueryReplies.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
this.QueryReplies[i]['GroupID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.write(this.QueryReplies[i]['GroupName'], pos);
|
||||
pos += this.QueryReplies[i]['GroupName'].length;
|
||||
buf.writeInt32LE(this.QueryReplies[i]['Members'], pos);
|
||||
pos += 4;
|
||||
buf.writeFloatLE(this.QueryReplies[i]['SearchOrder'], pos);
|
||||
pos += 4;
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjAgentData: {
|
||||
AgentID: UUID
|
||||
} = {
|
||||
AgentID: UUID.zero()
|
||||
};
|
||||
newObjAgentData['AgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentData = newObjAgentData;
|
||||
const newObjQueryData: {
|
||||
QueryID: UUID
|
||||
} = {
|
||||
QueryID: UUID.zero()
|
||||
};
|
||||
newObjQueryData['QueryID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
this.QueryData = newObjQueryData;
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.QueryReplies = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjQueryReplies: {
|
||||
GroupID: UUID,
|
||||
GroupName: string,
|
||||
Members: number,
|
||||
SearchOrder: number
|
||||
} = {
|
||||
GroupID: UUID.zero(),
|
||||
GroupName: '',
|
||||
Members: 0,
|
||||
SearchOrder: 0
|
||||
};
|
||||
newObjQueryReplies['GroupID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjQueryReplies['GroupName'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjQueryReplies['Members'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjQueryReplies['SearchOrder'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
this.QueryReplies.push(newObjQueryReplies);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user