// This file has been automatically generated by writeMessageClasses.js import {UUID} from '../UUID'; import {Vector3} from '../Vector3'; import {MessageFlags} from '../../enums/MessageFlags'; import {MessageBase} from '../MessageBase'; import {Message} from '../../enums/Message'; export class SendPostcardMessage implements MessageBase { name = 'SendPostcard'; messageFlags = MessageFlags.FrequencyLow; id = Message.SendPostcard; AgentData: { AgentID: UUID; SessionID: UUID; AssetID: UUID; PosGlobal: Vector3; To: Buffer; From: Buffer; Name: Buffer; Subject: Buffer; Msg: Buffer; AllowPublish: boolean; MaturePublish: boolean; }; getSize(): number { return (this.AgentData['To'].length + 1 + this.AgentData['From'].length + 1 + this.AgentData['Name'].length + 1 + this.AgentData['Subject'].length + 1 + this.AgentData['Msg'].length + 2) + 74; } 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.AgentData['AssetID'].writeToBuffer(buf, pos); pos += 16; this.AgentData['PosGlobal'].writeToBuffer(buf, pos, true); pos += 24; buf.writeUInt8(this.AgentData['To'].length, pos++); this.AgentData['To'].copy(buf, pos); pos += this.AgentData['To'].length; buf.writeUInt8(this.AgentData['From'].length, pos++); this.AgentData['From'].copy(buf, pos); pos += this.AgentData['From'].length; buf.writeUInt8(this.AgentData['Name'].length, pos++); this.AgentData['Name'].copy(buf, pos); pos += this.AgentData['Name'].length; buf.writeUInt8(this.AgentData['Subject'].length, pos++); this.AgentData['Subject'].copy(buf, pos); pos += this.AgentData['Subject'].length; buf.writeUInt16LE(this.AgentData['Msg'].length, pos); pos += 2; this.AgentData['Msg'].copy(buf, pos); pos += this.AgentData['Msg'].length; buf.writeUInt8((this.AgentData['AllowPublish']) ? 1 : 0, pos++); buf.writeUInt8((this.AgentData['MaturePublish']) ? 1 : 0, pos++); return pos - startPos; } readFromBuffer(buf: Buffer, pos: number): number { const startPos = pos; let varLength = 0; const newObjAgentData: { AgentID: UUID, SessionID: UUID, AssetID: UUID, PosGlobal: Vector3, To: Buffer, From: Buffer, Name: Buffer, Subject: Buffer, Msg: Buffer, AllowPublish: boolean, MaturePublish: boolean } = { AgentID: UUID.zero(), SessionID: UUID.zero(), AssetID: UUID.zero(), PosGlobal: Vector3.getZero(), To: Buffer.allocUnsafe(0), From: Buffer.allocUnsafe(0), Name: Buffer.allocUnsafe(0), Subject: Buffer.allocUnsafe(0), Msg: Buffer.allocUnsafe(0), AllowPublish: false, MaturePublish: false }; newObjAgentData['AgentID'] = new UUID(buf, pos); pos += 16; newObjAgentData['SessionID'] = new UUID(buf, pos); pos += 16; newObjAgentData['AssetID'] = new UUID(buf, pos); pos += 16; newObjAgentData['PosGlobal'] = new Vector3(buf, pos, true); pos += 24; varLength = buf.readUInt8(pos++); newObjAgentData['To'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); newObjAgentData['From'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); newObjAgentData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); newObjAgentData['Subject'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; newObjAgentData['Msg'] = buf.slice(pos, pos + varLength); pos += varLength; newObjAgentData['AllowPublish'] = (buf.readUInt8(pos++) === 1); newObjAgentData['MaturePublish'] = (buf.readUInt8(pos++) === 1); this.AgentData = newObjAgentData; return pos - startPos; } }