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

74 lines
2.1 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 CreateGroupReplyMessage implements MessageBase
{
name = 'CreateGroupReply';
messageFlags = MessageFlags.Trusted | MessageFlags.FrequencyLow;
id = Message.CreateGroupReply;
AgentData: {
AgentID: UUID;
};
ReplyData: {
GroupID: UUID;
Success: boolean;
Message: string;
};
getSize(): number
{
return (this.ReplyData['Message'].length + 1) + 33;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.AgentData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
this.ReplyData['GroupID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt8((this.ReplyData['Success']) ? 1 : 0, pos++);
buf.writeUInt8(this.ReplyData['Message'].length, pos++);
buf.write(this.ReplyData['Message'], pos);
pos += this.ReplyData['Message'].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 newObjReplyData: {
GroupID: UUID,
Success: boolean,
Message: string
} = {
GroupID: UUID.zero(),
Success: false,
Message: ''
};
newObjReplyData['GroupID'] = new UUID(buf, pos);
pos += 16;
newObjReplyData['Success'] = (buf.readUInt8(pos++) === 1);
varLength = buf.readUInt8(pos++);
newObjReplyData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1));
pos += varLength;
this.ReplyData = newObjReplyData;
return pos - startPos;
}
}