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

65 lines
1.8 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 InitiateDownloadPacket implements Packet
{
name = 'InitiateDownload';
flags = MessageFlags.FrequencyLow;
id = 4294902163;
AgentData: {
AgentID: UUID;
};
FileData: {
SimFilename: string;
ViewerFilename: string;
};
getSize(): number
{
return (this.FileData['SimFilename'].length + 1 + this.FileData['ViewerFilename'].length + 1) + 16;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.AgentData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
buf.write(this.FileData['SimFilename'], pos);
pos += this.FileData['SimFilename'].length;
buf.write(this.FileData['ViewerFilename'], pos);
pos += this.FileData['ViewerFilename'].length;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjAgentData: {
AgentID: UUID
} = {
AgentID: UUID.zero()
};
newObjAgentData['AgentID'] = new UUID(buf, pos);
pos += 16;
this.AgentData = newObjAgentData;
const newObjFileData: {
SimFilename: string,
ViewerFilename: string
} = {
SimFilename: '',
ViewerFilename: ''
};
newObjFileData['SimFilename'] = buf.toString('utf8', pos, length);
pos += length;
newObjFileData['ViewerFilename'] = buf.toString('utf8', pos, length);
pos += length;
this.FileData = newObjFileData;
return pos - startPos;
}
}