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

102 lines
3.6 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 * as Long from 'long';
import { MessageFlags } from '../../enums/MessageFlags';
import { MessageBase } from '../MessageBase';
import { Message } from '../../enums/Message';
2017-11-26 01:14:02 +00:00
export class AgentDataUpdateMessage implements MessageBase
{
name = 'AgentDataUpdate';
messageFlags = MessageFlags.Trusted | MessageFlags.Zerocoded | MessageFlags.FrequencyLow;
id = Message.AgentDataUpdate;
AgentData: {
AgentID: UUID;
FirstName: Buffer;
LastName: Buffer;
GroupTitle: Buffer;
2017-11-26 01:14:02 +00:00
ActiveGroupID: UUID;
GroupPowers: Long;
GroupName: Buffer;
2017-11-26 01:14:02 +00:00
};
getSize(): number
{
return (this.AgentData['FirstName'].length + 1 + this.AgentData['LastName'].length + 1 + this.AgentData['GroupTitle'].length + 1 + this.AgentData['GroupName'].length + 1) + 40;
}
// @ts-ignore
2017-11-26 01:14:02 +00:00
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.AgentData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt8(this.AgentData['FirstName'].length, pos++);
this.AgentData['FirstName'].copy(buf, pos);
2017-11-26 01:14:02 +00:00
pos += this.AgentData['FirstName'].length;
buf.writeUInt8(this.AgentData['LastName'].length, pos++);
this.AgentData['LastName'].copy(buf, pos);
2017-11-26 01:14:02 +00:00
pos += this.AgentData['LastName'].length;
buf.writeUInt8(this.AgentData['GroupTitle'].length, pos++);
this.AgentData['GroupTitle'].copy(buf, pos);
2017-11-26 01:14:02 +00:00
pos += this.AgentData['GroupTitle'].length;
this.AgentData['ActiveGroupID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeInt32LE(this.AgentData['GroupPowers'].low, pos);
pos += 4;
buf.writeInt32LE(this.AgentData['GroupPowers'].high, pos);
pos += 4;
buf.writeUInt8(this.AgentData['GroupName'].length, pos++);
this.AgentData['GroupName'].copy(buf, pos);
2017-11-26 01:14:02 +00:00
pos += this.AgentData['GroupName'].length;
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 newObjAgentData: {
AgentID: UUID,
FirstName: Buffer,
LastName: Buffer,
GroupTitle: Buffer,
2017-11-26 01:14:02 +00:00
ActiveGroupID: UUID,
GroupPowers: Long,
GroupName: Buffer
2017-11-26 01:14:02 +00:00
} = {
AgentID: UUID.zero(),
FirstName: Buffer.allocUnsafe(0),
LastName: Buffer.allocUnsafe(0),
GroupTitle: Buffer.allocUnsafe(0),
2017-11-26 01:14:02 +00:00
ActiveGroupID: UUID.zero(),
GroupPowers: Long.ZERO,
GroupName: Buffer.allocUnsafe(0)
2017-11-26 01:14:02 +00:00
};
newObjAgentData['AgentID'] = new UUID(buf, pos);
pos += 16;
varLength = buf.readUInt8(pos++);
newObjAgentData['FirstName'] = buf.slice(pos, pos + varLength);
2017-11-26 01:14:02 +00:00
pos += varLength;
varLength = buf.readUInt8(pos++);
newObjAgentData['LastName'] = buf.slice(pos, pos + varLength);
2017-11-26 01:14:02 +00:00
pos += varLength;
varLength = buf.readUInt8(pos++);
newObjAgentData['GroupTitle'] = buf.slice(pos, pos + varLength);
2017-11-26 01:14:02 +00:00
pos += varLength;
newObjAgentData['ActiveGroupID'] = new UUID(buf, pos);
pos += 16;
newObjAgentData['GroupPowers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
pos += 8;
varLength = buf.readUInt8(pos++);
newObjAgentData['GroupName'] = buf.slice(pos, pos + varLength);
2017-11-26 01:14:02 +00:00
pos += varLength;
this.AgentData = newObjAgentData;
return pos - startPos;
}
}