Files
node-metaverse/lib/classes/messages/AvatarPropertiesUpdate.ts
2017-11-26 01:14:02 +00:00

113 lines
4.0 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 AvatarPropertiesUpdateMessage implements MessageBase
{
name = 'AvatarPropertiesUpdate';
messageFlags = MessageFlags.Zerocoded | MessageFlags.FrequencyLow;
id = Message.AvatarPropertiesUpdate;
AgentData: {
AgentID: UUID;
SessionID: UUID;
};
PropertiesData: {
ImageID: UUID;
FLImageID: UUID;
AboutText: string;
FLAboutText: string;
AllowPublish: boolean;
MaturePublish: boolean;
ProfileURL: string;
};
getSize(): number
{
return (this.PropertiesData['AboutText'].length + 2 + this.PropertiesData['FLAboutText'].length + 1 + this.PropertiesData['ProfileURL'].length + 1) + 66;
}
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;
this.PropertiesData['ImageID'].writeToBuffer(buf, pos);
pos += 16;
this.PropertiesData['FLImageID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt16LE(this.PropertiesData['AboutText'].length, pos);
pos += 2;
buf.write(this.PropertiesData['AboutText'], pos);
pos += this.PropertiesData['AboutText'].length;
buf.writeUInt8(this.PropertiesData['FLAboutText'].length, pos++);
buf.write(this.PropertiesData['FLAboutText'], pos);
pos += this.PropertiesData['FLAboutText'].length;
buf.writeUInt8((this.PropertiesData['AllowPublish']) ? 1 : 0, pos++);
buf.writeUInt8((this.PropertiesData['MaturePublish']) ? 1 : 0, pos++);
buf.writeUInt8(this.PropertiesData['ProfileURL'].length, pos++);
buf.write(this.PropertiesData['ProfileURL'], pos);
pos += this.PropertiesData['ProfileURL'].length;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
let varLength = 0;
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 newObjPropertiesData: {
ImageID: UUID,
FLImageID: UUID,
AboutText: string,
FLAboutText: string,
AllowPublish: boolean,
MaturePublish: boolean,
ProfileURL: string
} = {
ImageID: UUID.zero(),
FLImageID: UUID.zero(),
AboutText: '',
FLAboutText: '',
AllowPublish: false,
MaturePublish: false,
ProfileURL: ''
};
newObjPropertiesData['ImageID'] = new UUID(buf, pos);
pos += 16;
newObjPropertiesData['FLImageID'] = new UUID(buf, pos);
pos += 16;
varLength = buf.readUInt16LE(pos);
pos += 2;
newObjPropertiesData['AboutText'] = buf.toString('utf8', pos, pos + (varLength - 1));
pos += varLength;
varLength = buf.readUInt8(pos++);
newObjPropertiesData['FLAboutText'] = buf.toString('utf8', pos, pos + (varLength - 1));
pos += varLength;
newObjPropertiesData['AllowPublish'] = (buf.readUInt8(pos++) === 1);
newObjPropertiesData['MaturePublish'] = (buf.readUInt8(pos++) === 1);
varLength = buf.readUInt8(pos++);
newObjPropertiesData['ProfileURL'] = buf.toString('utf8', pos, pos + (varLength - 1));
pos += varLength;
this.PropertiesData = newObjPropertiesData;
return pos - startPos;
}
}