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

88 lines
2.8 KiB
TypeScript

// This file has been automatically generated by writeMessageClasses.js
import {UUID} from '../UUID';
import Long = require('long');
import {MessageFlags} from '../../enums/MessageFlags';
import {MessageBase} from '../MessageBase';
import {Message} from '../../enums/Message';
export class RequestXferMessage implements MessageBase
{
name = 'RequestXfer';
messageFlags = MessageFlags.Zerocoded | MessageFlags.FrequencyLow;
id = Message.RequestXfer;
XferID: {
ID: Long;
Filename: Buffer;
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.writeUInt8(this.XferID['Filename'].length, pos++);
this.XferID['Filename'].copy(buf, 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;
let varLength = 0;
const newObjXferID: {
ID: Long,
Filename: Buffer,
FilePath: number,
DeleteOnCompletion: boolean,
UseBigPackets: boolean,
VFileID: UUID,
VFileType: number
} = {
ID: Long.ZERO,
Filename: Buffer.allocUnsafe(0),
FilePath: 0,
DeleteOnCompletion: false,
UseBigPackets: false,
VFileID: UUID.zero(),
VFileType: 0
};
newObjXferID['ID'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
pos += 8;
varLength = buf.readUInt8(pos++);
newObjXferID['Filename'] = buf.slice(pos, pos + varLength);
pos += varLength;
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;
}
}