Files
node-metaverse/dist/classes/messages/CreateLandmarkForEvent.js
2017-12-13 15:23:50 +00:00

62 lines
2.4 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const UUID_1 = require("../UUID");
const MessageFlags_1 = require("../../enums/MessageFlags");
const Message_1 = require("../../enums/Message");
class CreateLandmarkForEventMessage {
constructor() {
this.name = 'CreateLandmarkForEvent';
this.messageFlags = MessageFlags_1.MessageFlags.Zerocoded | MessageFlags_1.MessageFlags.FrequencyLow;
this.id = Message_1.Message.CreateLandmarkForEvent;
}
getSize() {
return (this.InventoryBlock['Name'].length + 1) + 52;
}
writeToBuffer(buf, pos) {
const startPos = pos;
this.AgentData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
this.AgentData['SessionID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt32LE(this.EventData['EventID'], pos);
pos += 4;
this.InventoryBlock['FolderID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt8(this.InventoryBlock['Name'].length, pos++);
this.InventoryBlock['Name'].copy(buf, pos);
pos += this.InventoryBlock['Name'].length;
return pos - startPos;
}
readFromBuffer(buf, pos) {
const startPos = pos;
let varLength = 0;
const newObjAgentData = {
AgentID: UUID_1.UUID.zero(),
SessionID: UUID_1.UUID.zero()
};
newObjAgentData['AgentID'] = new UUID_1.UUID(buf, pos);
pos += 16;
newObjAgentData['SessionID'] = new UUID_1.UUID(buf, pos);
pos += 16;
this.AgentData = newObjAgentData;
const newObjEventData = {
EventID: 0
};
newObjEventData['EventID'] = buf.readUInt32LE(pos);
pos += 4;
this.EventData = newObjEventData;
const newObjInventoryBlock = {
FolderID: UUID_1.UUID.zero(),
Name: Buffer.allocUnsafe(0)
};
newObjInventoryBlock['FolderID'] = new UUID_1.UUID(buf, pos);
pos += 16;
varLength = buf.readUInt8(pos++);
newObjInventoryBlock['Name'] = buf.slice(pos, pos + varLength);
pos += varLength;
this.InventoryBlock = newObjInventoryBlock;
return pos - startPos;
}
}
exports.CreateLandmarkForEventMessage = CreateLandmarkForEventMessage;
//# sourceMappingURL=CreateLandmarkForEvent.js.map