96 lines
2.8 KiB
TypeScript
96 lines
2.8 KiB
TypeScript
// This file has been automatically generated by writeMessageClasses.js
|
|
|
|
import {UUID} from '../UUID';
|
|
import {MessageFlags} from '../../enums/MessageFlags';
|
|
import {MessageBase} from '../MessageBase';
|
|
import {Message} from '../../enums/Message';
|
|
|
|
export class AvatarClassifiedReplyMessage implements MessageBase
|
|
{
|
|
name = 'AvatarClassifiedReply';
|
|
messageFlags = MessageFlags.Trusted | MessageFlags.FrequencyLow;
|
|
id = Message.AvatarClassifiedReply;
|
|
|
|
AgentData: {
|
|
AgentID: UUID;
|
|
TargetID: UUID;
|
|
};
|
|
Data: {
|
|
ClassifiedID: UUID;
|
|
Name: Buffer;
|
|
}[];
|
|
|
|
getSize(): number
|
|
{
|
|
return this.calculateVarVarSize(this.Data, 'Name', 1) + ((16) * this.Data.length) + 33;
|
|
}
|
|
|
|
calculateVarVarSize(block: object[], paramName: string, extraPerVar: number): number
|
|
{
|
|
let size = 0;
|
|
block.forEach((bl: any) =>
|
|
{
|
|
size += bl[paramName].length + extraPerVar;
|
|
});
|
|
return size;
|
|
}
|
|
|
|
writeToBuffer(buf: Buffer, pos: number): number
|
|
{
|
|
const startPos = pos;
|
|
this.AgentData['AgentID'].writeToBuffer(buf, pos);
|
|
pos += 16;
|
|
this.AgentData['TargetID'].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]['ClassifiedID'].writeToBuffer(buf, pos);
|
|
pos += 16;
|
|
buf.writeUInt8(this.Data[i]['Name'].length, pos++);
|
|
this.Data[i]['Name'].copy(buf, pos);
|
|
pos += this.Data[i]['Name'].length;
|
|
}
|
|
return pos - startPos;
|
|
}
|
|
|
|
readFromBuffer(buf: Buffer, pos: number): number
|
|
{
|
|
const startPos = pos;
|
|
let varLength = 0;
|
|
const newObjAgentData: {
|
|
AgentID: UUID,
|
|
TargetID: UUID
|
|
} = {
|
|
AgentID: UUID.zero(),
|
|
TargetID: UUID.zero()
|
|
};
|
|
newObjAgentData['AgentID'] = new UUID(buf, pos);
|
|
pos += 16;
|
|
newObjAgentData['TargetID'] = 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: {
|
|
ClassifiedID: UUID,
|
|
Name: Buffer
|
|
} = {
|
|
ClassifiedID: UUID.zero(),
|
|
Name: Buffer.allocUnsafe(0)
|
|
};
|
|
newObjData['ClassifiedID'] = new UUID(buf, pos);
|
|
pos += 16;
|
|
varLength = buf.readUInt8(pos++);
|
|
newObjData['Name'] = buf.slice(pos, pos + varLength);
|
|
pos += varLength;
|
|
this.Data.push(newObjData);
|
|
}
|
|
return pos - startPos;
|
|
}
|
|
}
|
|
|