Files
node-metaverse/lib/classes/packets/LinkInventoryItem.ts

110 lines
3.5 KiB
TypeScript

// This file has been automatically generated by writePacketClasses.js
import {UUID} from '../UUID';
import {MessageFlags} from '../../enums/MessageFlags';
import {Packet} from '../Packet';
export class LinkInventoryItemPacket implements Packet
{
name = 'LinkInventoryItem';
flags = MessageFlags.Zerocoded | MessageFlags.FrequencyLow;
id = 4294902186;
AgentData: {
AgentID: UUID;
SessionID: UUID;
};
InventoryBlock: {
CallbackID: number;
FolderID: UUID;
TransactionID: UUID;
OldItemID: UUID;
Type: number;
InvType: number;
Name: string;
Description: string;
};
getSize(): number
{
return (this.InventoryBlock['Name'].length + 1 + this.InventoryBlock['Description'].length + 1) + 86;
}
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;
buf.writeUInt32LE(this.InventoryBlock['CallbackID'], pos);
pos += 4;
this.InventoryBlock['FolderID'].writeToBuffer(buf, pos);
pos += 16;
this.InventoryBlock['TransactionID'].writeToBuffer(buf, pos);
pos += 16;
this.InventoryBlock['OldItemID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeInt8(this.InventoryBlock['Type'], pos++);
buf.writeInt8(this.InventoryBlock['InvType'], pos++);
buf.write(this.InventoryBlock['Name'], pos);
pos += this.InventoryBlock['Name'].length;
buf.write(this.InventoryBlock['Description'], pos);
pos += this.InventoryBlock['Description'].length;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjAgentData: {
AgentID: UUID,
SessionID: UUID
} = {
AgentID: UUID.zero(),
SessionID: UUID.zero()
};
newObjAgentData['AgentID'] = new UUID(buf, pos);
pos += 16;
newObjAgentData['SessionID'] = new UUID(buf, pos);
pos += 16;
this.AgentData = newObjAgentData;
const newObjInventoryBlock: {
CallbackID: number,
FolderID: UUID,
TransactionID: UUID,
OldItemID: UUID,
Type: number,
InvType: number,
Name: string,
Description: string
} = {
CallbackID: 0,
FolderID: UUID.zero(),
TransactionID: UUID.zero(),
OldItemID: UUID.zero(),
Type: 0,
InvType: 0,
Name: '',
Description: ''
};
newObjInventoryBlock['CallbackID'] = buf.readUInt32LE(pos);
pos += 4;
newObjInventoryBlock['FolderID'] = new UUID(buf, pos);
pos += 16;
newObjInventoryBlock['TransactionID'] = new UUID(buf, pos);
pos += 16;
newObjInventoryBlock['OldItemID'] = new UUID(buf, pos);
pos += 16;
newObjInventoryBlock['Type'] = buf.readInt8(pos++);
newObjInventoryBlock['InvType'] = buf.readInt8(pos++);
newObjInventoryBlock['Name'] = buf.toString('utf8', pos, length);
pos += length;
newObjInventoryBlock['Description'] = buf.toString('utf8', pos, length);
pos += length;
this.InventoryBlock = newObjInventoryBlock;
return pos - startPos;
}
}