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

82 lines
3.2 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 DeRezObjectMessage {
constructor() {
this.name = 'DeRezObject';
this.messageFlags = MessageFlags_1.MessageFlags.Zerocoded | MessageFlags_1.MessageFlags.FrequencyLow;
this.id = Message_1.Message.DeRezObject;
}
getSize() {
return ((4) * this.ObjectData.length) + 84;
}
writeToBuffer(buf, pos) {
const startPos = pos;
this.AgentData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
this.AgentData['SessionID'].writeToBuffer(buf, pos);
pos += 16;
this.AgentBlock['GroupID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt8(this.AgentBlock['Destination'], pos++);
this.AgentBlock['DestinationID'].writeToBuffer(buf, pos);
pos += 16;
this.AgentBlock['TransactionID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt8(this.AgentBlock['PacketCount'], pos++);
buf.writeUInt8(this.AgentBlock['PacketNumber'], pos++);
const count = this.ObjectData.length;
buf.writeUInt8(this.ObjectData.length, pos++);
for (let i = 0; i < count; i++) {
buf.writeUInt32LE(this.ObjectData[i]['ObjectLocalID'], pos);
pos += 4;
}
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 newObjAgentBlock = {
GroupID: UUID_1.UUID.zero(),
Destination: 0,
DestinationID: UUID_1.UUID.zero(),
TransactionID: UUID_1.UUID.zero(),
PacketCount: 0,
PacketNumber: 0
};
newObjAgentBlock['GroupID'] = new UUID_1.UUID(buf, pos);
pos += 16;
newObjAgentBlock['Destination'] = buf.readUInt8(pos++);
newObjAgentBlock['DestinationID'] = new UUID_1.UUID(buf, pos);
pos += 16;
newObjAgentBlock['TransactionID'] = new UUID_1.UUID(buf, pos);
pos += 16;
newObjAgentBlock['PacketCount'] = buf.readUInt8(pos++);
newObjAgentBlock['PacketNumber'] = buf.readUInt8(pos++);
this.AgentBlock = newObjAgentBlock;
const count = buf.readUInt8(pos++);
this.ObjectData = [];
for (let i = 0; i < count; i++) {
const newObjObjectData = {
ObjectLocalID: 0
};
newObjObjectData['ObjectLocalID'] = buf.readUInt32LE(pos);
pos += 4;
this.ObjectData.push(newObjObjectData);
}
return pos - startPos;
}
}
exports.DeRezObjectMessage = DeRezObjectMessage;
//# sourceMappingURL=DeRezObject.js.map