Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -38,4 +38,112 @@ export class ImprovedInstantMessagePacket implements Packet
|
||||
return (this.MessageBlock['FromAgentName'].length + 1 + this.MessageBlock['Message'].length + 2 + this.MessageBlock['BinaryBucket'].length + 2) + 107;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
this.AgentData['AgentID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentData['SessionID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt8((this.MessageBlock['FromGroup']) ? 1 : 0, pos++);
|
||||
this.MessageBlock['ToAgentID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt32LE(this.MessageBlock['ParentEstateID'], pos);
|
||||
pos += 4;
|
||||
this.MessageBlock['RegionID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.MessageBlock['Position'].writeToBuffer(buf, pos, false);
|
||||
pos += 12;
|
||||
buf.writeUInt8(this.MessageBlock['Offline'], pos++);
|
||||
buf.writeUInt8(this.MessageBlock['Dialog'], pos++);
|
||||
this.MessageBlock['ID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt32LE(this.MessageBlock['Timestamp'], pos);
|
||||
pos += 4;
|
||||
buf.write(this.MessageBlock['FromAgentName'], pos);
|
||||
pos += this.MessageBlock['FromAgentName'].length;
|
||||
buf.write(this.MessageBlock['Message'], pos);
|
||||
pos += this.MessageBlock['Message'].length;
|
||||
buf.write(this.MessageBlock['BinaryBucket'], pos);
|
||||
pos += this.MessageBlock['BinaryBucket'].length;
|
||||
buf.writeUInt32LE(this.EstateBlock['EstateID'], pos);
|
||||
pos += 4;
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjAgentData: {
|
||||
AgentID: UUID,
|
||||
SessionID: UUID
|
||||
} = {
|
||||
AgentID: UUID.zero(),
|
||||
SessionID: UUID.zero()
|
||||
};
|
||||
newObjAgentData['AgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentData['SessionID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentData = newObjAgentData;
|
||||
const newObjMessageBlock: {
|
||||
FromGroup: boolean,
|
||||
ToAgentID: UUID,
|
||||
ParentEstateID: number,
|
||||
RegionID: UUID,
|
||||
Position: Vector3,
|
||||
Offline: number,
|
||||
Dialog: number,
|
||||
ID: UUID,
|
||||
Timestamp: number,
|
||||
FromAgentName: string,
|
||||
Message: string,
|
||||
BinaryBucket: string
|
||||
} = {
|
||||
FromGroup: false,
|
||||
ToAgentID: UUID.zero(),
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID.zero(),
|
||||
Position: Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: 0,
|
||||
ID: UUID.zero(),
|
||||
Timestamp: 0,
|
||||
FromAgentName: '',
|
||||
Message: '',
|
||||
BinaryBucket: ''
|
||||
};
|
||||
newObjMessageBlock['FromGroup'] = (buf.readUInt8(pos++) === 1);
|
||||
newObjMessageBlock['ToAgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjMessageBlock['ParentEstateID'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjMessageBlock['RegionID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjMessageBlock['Position'] = new Vector3(buf, pos, false);
|
||||
pos += 12;
|
||||
newObjMessageBlock['Offline'] = buf.readUInt8(pos++);
|
||||
newObjMessageBlock['Dialog'] = buf.readUInt8(pos++);
|
||||
newObjMessageBlock['ID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjMessageBlock['Timestamp'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjMessageBlock['FromAgentName'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjMessageBlock['Message'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjMessageBlock['BinaryBucket'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
this.MessageBlock = newObjMessageBlock;
|
||||
const newObjEstateBlock: {
|
||||
EstateID: number
|
||||
} = {
|
||||
EstateID: 0
|
||||
};
|
||||
newObjEstateBlock['EstateID'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
this.EstateBlock = newObjEstateBlock;
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user