2017-11-26 01:14:02 +00:00
|
|
|
// This file has been automatically generated by writeMessageClasses.js
|
|
|
|
|
|
2020-01-06 12:10:40 +00:00
|
|
|
import { UUID } from '../UUID';
|
|
|
|
|
import { MessageFlags } from '../../enums/MessageFlags';
|
|
|
|
|
import { MessageBase } from '../MessageBase';
|
|
|
|
|
import { Message } from '../../enums/Message';
|
2017-11-26 01:14:02 +00:00
|
|
|
|
|
|
|
|
export class UUIDGroupNameReplyMessage implements MessageBase
|
|
|
|
|
{
|
|
|
|
|
name = 'UUIDGroupNameReply';
|
|
|
|
|
messageFlags = MessageFlags.Trusted | MessageFlags.FrequencyLow;
|
|
|
|
|
id = Message.UUIDGroupNameReply;
|
|
|
|
|
|
|
|
|
|
UUIDNameBlock: {
|
|
|
|
|
ID: UUID;
|
2017-11-26 19:47:41 +00:00
|
|
|
GroupName: Buffer;
|
2017-11-26 01:14:02 +00:00
|
|
|
}[];
|
|
|
|
|
|
|
|
|
|
getSize(): number
|
|
|
|
|
{
|
2017-12-20 17:07:10 +00:00
|
|
|
return this.calculateVarVarSize(this.UUIDNameBlock, 'GroupName', 1) + ((16) * this.UUIDNameBlock.length) + 1;
|
2017-11-26 01:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-19 16:27:29 +00:00
|
|
|
calculateVarVarSize(block: {[key: string]: any}[], paramName: string, extraPerVar: number): number
|
2017-11-26 01:14:02 +00:00
|
|
|
{
|
|
|
|
|
let size = 0;
|
2020-11-19 16:27:29 +00:00
|
|
|
for (const bl of block)
|
2017-11-26 01:14:02 +00:00
|
|
|
{
|
|
|
|
|
size += bl[paramName].length + extraPerVar;
|
2020-11-19 16:27:29 +00:00
|
|
|
}
|
2017-11-26 01:14:02 +00:00
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 13:55:02 +00:00
|
|
|
// @ts-ignore
|
2017-11-26 01:14:02 +00:00
|
|
|
writeToBuffer(buf: Buffer, pos: number): number
|
|
|
|
|
{
|
|
|
|
|
const startPos = pos;
|
|
|
|
|
const count = this.UUIDNameBlock.length;
|
|
|
|
|
buf.writeUInt8(this.UUIDNameBlock.length, pos++);
|
|
|
|
|
for (let i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
this.UUIDNameBlock[i]['ID'].writeToBuffer(buf, pos);
|
|
|
|
|
pos += 16;
|
|
|
|
|
buf.writeUInt8(this.UUIDNameBlock[i]['GroupName'].length, pos++);
|
2017-11-26 19:47:41 +00:00
|
|
|
this.UUIDNameBlock[i]['GroupName'].copy(buf, pos);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += this.UUIDNameBlock[i]['GroupName'].length;
|
|
|
|
|
}
|
|
|
|
|
return pos - startPos;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 13:55:02 +00:00
|
|
|
// @ts-ignore
|
2017-11-26 01:14:02 +00:00
|
|
|
readFromBuffer(buf: Buffer, pos: number): number
|
|
|
|
|
{
|
|
|
|
|
const startPos = pos;
|
|
|
|
|
let varLength = 0;
|
2020-01-06 12:10:40 +00:00
|
|
|
if (pos >= buf.length)
|
|
|
|
|
{
|
|
|
|
|
return pos - startPos;
|
|
|
|
|
}
|
2017-11-26 01:14:02 +00:00
|
|
|
const count = buf.readUInt8(pos++);
|
|
|
|
|
this.UUIDNameBlock = [];
|
|
|
|
|
for (let i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
const newObjUUIDNameBlock: {
|
|
|
|
|
ID: UUID,
|
2017-11-26 19:47:41 +00:00
|
|
|
GroupName: Buffer
|
2017-11-26 01:14:02 +00:00
|
|
|
} = {
|
|
|
|
|
ID: UUID.zero(),
|
2017-11-26 19:47:41 +00:00
|
|
|
GroupName: Buffer.allocUnsafe(0)
|
2017-11-26 01:14:02 +00:00
|
|
|
};
|
|
|
|
|
newObjUUIDNameBlock['ID'] = new UUID(buf, pos);
|
|
|
|
|
pos += 16;
|
|
|
|
|
varLength = buf.readUInt8(pos++);
|
2017-11-30 04:11:59 +00:00
|
|
|
newObjUUIDNameBlock['GroupName'] = buf.slice(pos, pos + varLength);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += varLength;
|
|
|
|
|
this.UUIDNameBlock.push(newObjUUIDNameBlock);
|
|
|
|
|
}
|
|
|
|
|
return pos - startPos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|