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

103 lines
3.4 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 GroupNoticeAddMessage implements MessageBase
{
name = 'GroupNoticeAdd';
messageFlags = MessageFlags.Trusted | MessageFlags.FrequencyLow;
id = Message.GroupNoticeAdd;
AgentData: {
AgentID: UUID;
};
MessageBlock: {
ToGroupID: UUID;
ID: UUID;
Dialog: number;
FromAgentName: string;
Message: string;
BinaryBucket: string;
};
getSize(): number
{
return (this.MessageBlock['FromAgentName'].length + 1 + this.MessageBlock['Message'].length + 2 + this.MessageBlock['BinaryBucket'].length + 2) + 49;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.AgentData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
this.MessageBlock['ToGroupID'].writeToBuffer(buf, pos);
pos += 16;
this.MessageBlock['ID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt8(this.MessageBlock['Dialog'], pos++);
buf.writeUInt8(this.MessageBlock['FromAgentName'].length, pos++);
buf.write(this.MessageBlock['FromAgentName'], pos);
pos += this.MessageBlock['FromAgentName'].length;
buf.writeUInt16LE(this.MessageBlock['Message'].length, pos);
pos += 2;
buf.write(this.MessageBlock['Message'], pos);
pos += this.MessageBlock['Message'].length;
buf.writeUInt16LE(this.MessageBlock['BinaryBucket'].length, pos);
pos += 2;
buf.write(this.MessageBlock['BinaryBucket'], pos);
pos += this.MessageBlock['BinaryBucket'].length;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
let varLength = 0;
const newObjAgentData: {
AgentID: UUID
} = {
AgentID: UUID.zero()
};
newObjAgentData['AgentID'] = new UUID(buf, pos);
pos += 16;
this.AgentData = newObjAgentData;
const newObjMessageBlock: {
ToGroupID: UUID,
ID: UUID,
Dialog: number,
FromAgentName: string,
Message: string,
BinaryBucket: string
} = {
ToGroupID: UUID.zero(),
ID: UUID.zero(),
Dialog: 0,
FromAgentName: '',
Message: '',
BinaryBucket: ''
};
newObjMessageBlock['ToGroupID'] = new UUID(buf, pos);
pos += 16;
newObjMessageBlock['ID'] = new UUID(buf, pos);
pos += 16;
newObjMessageBlock['Dialog'] = buf.readUInt8(pos++);
varLength = buf.readUInt8(pos++);
newObjMessageBlock['FromAgentName'] = buf.toString('utf8', pos, pos + (varLength - 1));
pos += varLength;
varLength = buf.readUInt16LE(pos);
pos += 2;
newObjMessageBlock['Message'] = buf.toString('utf8', pos, pos + (varLength - 1));
pos += varLength;
varLength = buf.readUInt16LE(pos);
pos += 2;
newObjMessageBlock['BinaryBucket'] = buf.toString('utf8', pos, pos + (varLength - 1));
pos += varLength;
this.MessageBlock = newObjMessageBlock;
return pos - startPos;
}
}