Files
node-metaverse/lib/classes/messages/EmailMessageReply.ts
2017-11-26 01:14:02 +00:00

99 lines
3.3 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 EmailMessageReplyMessage implements MessageBase
{
name = 'EmailMessageReply';
messageFlags = MessageFlags.Trusted | MessageFlags.FrequencyLow;
id = Message.EmailMessageReply;
DataBlock: {
ObjectID: UUID;
More: number;
Time: number;
FromAddress: string;
Subject: string;
Data: string;
MailFilter: string;
};
getSize(): number
{
return (this.DataBlock['FromAddress'].length + 1 + this.DataBlock['Subject'].length + 1 + this.DataBlock['Data'].length + 2 + this.DataBlock['MailFilter'].length + 1) + 24;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.DataBlock['ObjectID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt32LE(this.DataBlock['More'], pos);
pos += 4;
buf.writeUInt32LE(this.DataBlock['Time'], pos);
pos += 4;
buf.writeUInt8(this.DataBlock['FromAddress'].length, pos++);
buf.write(this.DataBlock['FromAddress'], pos);
pos += this.DataBlock['FromAddress'].length;
buf.writeUInt8(this.DataBlock['Subject'].length, pos++);
buf.write(this.DataBlock['Subject'], pos);
pos += this.DataBlock['Subject'].length;
buf.writeUInt16LE(this.DataBlock['Data'].length, pos);
pos += 2;
buf.write(this.DataBlock['Data'], pos);
pos += this.DataBlock['Data'].length;
buf.writeUInt8(this.DataBlock['MailFilter'].length, pos++);
buf.write(this.DataBlock['MailFilter'], pos);
pos += this.DataBlock['MailFilter'].length;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
let varLength = 0;
const newObjDataBlock: {
ObjectID: UUID,
More: number,
Time: number,
FromAddress: string,
Subject: string,
Data: string,
MailFilter: string
} = {
ObjectID: UUID.zero(),
More: 0,
Time: 0,
FromAddress: '',
Subject: '',
Data: '',
MailFilter: ''
};
newObjDataBlock['ObjectID'] = new UUID(buf, pos);
pos += 16;
newObjDataBlock['More'] = buf.readUInt32LE(pos);
pos += 4;
newObjDataBlock['Time'] = buf.readUInt32LE(pos);
pos += 4;
varLength = buf.readUInt8(pos++);
newObjDataBlock['FromAddress'] = buf.toString('utf8', pos, pos + (varLength - 1));
pos += varLength;
varLength = buf.readUInt8(pos++);
newObjDataBlock['Subject'] = buf.toString('utf8', pos, pos + (varLength - 1));
pos += varLength;
varLength = buf.readUInt16LE(pos);
pos += 2;
newObjDataBlock['Data'] = buf.toString('utf8', pos, pos + (varLength - 1));
pos += varLength;
varLength = buf.readUInt8(pos++);
newObjDataBlock['MailFilter'] = buf.toString('utf8', pos, pos + (varLength - 1));
pos += varLength;
this.DataBlock = newObjDataBlock;
return pos - startPos;
}
}