71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
// This file has been automatically generated by writeMessageClasses.js
|
|
|
|
import {UUID} from '../UUID';
|
|
import {MessageFlags} from '../../enums/MessageFlags';
|
|
import {MessageBase} from '../MessageBase';
|
|
import {Message} from '../../enums/Message';
|
|
|
|
export class InitiateDownloadMessage implements MessageBase
|
|
{
|
|
name = 'InitiateDownload';
|
|
messageFlags = MessageFlags.FrequencyLow;
|
|
id = Message.InitiateDownload;
|
|
|
|
AgentData: {
|
|
AgentID: UUID;
|
|
};
|
|
FileData: {
|
|
SimFilename: Buffer;
|
|
ViewerFilename: Buffer;
|
|
};
|
|
|
|
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.writeUInt8(this.FileData['SimFilename'].length, pos++);
|
|
this.FileData['SimFilename'].copy(buf, pos);
|
|
pos += this.FileData['SimFilename'].length;
|
|
buf.writeUInt8(this.FileData['ViewerFilename'].length, pos++);
|
|
this.FileData['ViewerFilename'].copy(buf, pos);
|
|
pos += this.FileData['ViewerFilename'].length;
|
|
return pos - startPos;
|
|
}
|
|
|
|
readFromBuffer(buf: Buffer, pos: number): number
|
|
{
|
|
const startPos = pos;
|
|
let varLength = 0;
|
|
const newObjAgentData: {
|
|
AgentID: UUID
|
|
} = {
|
|
AgentID: UUID.zero()
|
|
};
|
|
newObjAgentData['AgentID'] = new UUID(buf, pos);
|
|
pos += 16;
|
|
this.AgentData = newObjAgentData;
|
|
const newObjFileData: {
|
|
SimFilename: Buffer,
|
|
ViewerFilename: Buffer
|
|
} = {
|
|
SimFilename: Buffer.allocUnsafe(0),
|
|
ViewerFilename: Buffer.allocUnsafe(0)
|
|
};
|
|
varLength = buf.readUInt8(pos++);
|
|
newObjFileData['SimFilename'] = buf.slice(pos, pos + varLength);
|
|
pos += varLength;
|
|
varLength = buf.readUInt8(pos++);
|
|
newObjFileData['ViewerFilename'] = buf.slice(pos, pos + varLength);
|
|
pos += varLength;
|
|
this.FileData = newObjFileData;
|
|
return pos - startPos;
|
|
}
|
|
}
|
|
|