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

84 lines
2.6 KiB
TypeScript

// This file has been automatically generated by writePacketClasses.js
import {UUID} from '../UUID';
import Long = require('long');
import {MessageFlags} from '../../enums/MessageFlags';
import {Packet} from '../Packet';
export class RequestXferPacket implements Packet
{
name = 'RequestXfer';
flags = MessageFlags.Zerocoded | MessageFlags.FrequencyLow;
id = 4294901916;
XferID: {
ID: Long;
Filename: string;
FilePath: number;
DeleteOnCompletion: boolean;
UseBigPackets: boolean;
VFileID: UUID;
VFileType: number;
};
getSize(): number
{
return (this.XferID['Filename'].length + 1) + 29;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
buf.writeInt32LE(this.XferID['ID'].low, pos);
pos += 4;
buf.writeInt32LE(this.XferID['ID'].high, pos);
pos += 4;
buf.write(this.XferID['Filename'], pos);
pos += this.XferID['Filename'].length;
buf.writeUInt8(this.XferID['FilePath'], pos++);
buf.writeUInt8((this.XferID['DeleteOnCompletion']) ? 1 : 0, pos++);
buf.writeUInt8((this.XferID['UseBigPackets']) ? 1 : 0, pos++);
this.XferID['VFileID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeInt16LE(this.XferID['VFileType'], pos);
pos += 2;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjXferID: {
ID: Long,
Filename: string,
FilePath: number,
DeleteOnCompletion: boolean,
UseBigPackets: boolean,
VFileID: UUID,
VFileType: number
} = {
ID: Long.ZERO,
Filename: '',
FilePath: 0,
DeleteOnCompletion: false,
UseBigPackets: false,
VFileID: UUID.zero(),
VFileType: 0
};
newObjXferID['ID'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
pos += 8;
newObjXferID['Filename'] = buf.toString('utf8', pos, length);
pos += length;
newObjXferID['FilePath'] = buf.readUInt8(pos++);
newObjXferID['DeleteOnCompletion'] = (buf.readUInt8(pos++) === 1);
newObjXferID['UseBigPackets'] = (buf.readUInt8(pos++) === 1);
newObjXferID['VFileID'] = new UUID(buf, pos);
pos += 16;
newObjXferID['VFileType'] = buf.readInt16LE(pos);
pos += 2;
this.XferID = newObjXferID;
return pos - startPos;
}
}