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

70 lines
2.1 KiB
TypeScript
Raw Normal View History

2017-11-26 01:14:02 +00:00
// 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';
2017-11-26 01:14:02 +00:00
export class UpdateSimulatorMessage implements MessageBase
{
name = 'UpdateSimulator';
messageFlags = MessageFlags.Trusted | MessageFlags.FrequencyLow;
id = Message.UpdateSimulator;
SimulatorInfo: {
RegionID: UUID;
SimName: Buffer;
2017-11-26 01:14:02 +00:00
EstateID: number;
SimAccess: number;
};
getSize(): number
{
return (this.SimulatorInfo['SimName'].length + 1) + 21;
}
// @ts-ignore
2017-11-26 01:14:02 +00:00
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.SimulatorInfo['RegionID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt8(this.SimulatorInfo['SimName'].length, pos++);
this.SimulatorInfo['SimName'].copy(buf, pos);
2017-11-26 01:14:02 +00:00
pos += this.SimulatorInfo['SimName'].length;
buf.writeUInt32LE(this.SimulatorInfo['EstateID'], pos);
pos += 4;
buf.writeUInt8(this.SimulatorInfo['SimAccess'], pos++);
return pos - startPos;
}
// @ts-ignore
2017-11-26 01:14:02 +00:00
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
let varLength = 0;
const newObjSimulatorInfo: {
RegionID: UUID,
SimName: Buffer,
2017-11-26 01:14:02 +00:00
EstateID: number,
SimAccess: number
} = {
RegionID: UUID.zero(),
SimName: Buffer.allocUnsafe(0),
2017-11-26 01:14:02 +00:00
EstateID: 0,
SimAccess: 0
};
newObjSimulatorInfo['RegionID'] = new UUID(buf, pos);
pos += 16;
varLength = buf.readUInt8(pos++);
newObjSimulatorInfo['SimName'] = buf.slice(pos, pos + varLength);
2017-11-26 01:14:02 +00:00
pos += varLength;
newObjSimulatorInfo['EstateID'] = buf.readUInt32LE(pos);
pos += 4;
newObjSimulatorInfo['SimAccess'] = buf.readUInt8(pos++);
this.SimulatorInfo = newObjSimulatorInfo;
return pos - startPos;
}
}