Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -51,4 +51,144 @@ export class GroupVoteHistoryItemReplyPacket implements Packet
|
||||
return size;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
this.AgentData['AgentID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentData['GroupID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.TransactionData['TransactionID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt32LE(this.TransactionData['TotalNumItems'], pos);
|
||||
pos += 4;
|
||||
this.HistoryItemData['VoteID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.write(this.HistoryItemData['TerseDateID'], pos);
|
||||
pos += this.HistoryItemData['TerseDateID'].length;
|
||||
buf.write(this.HistoryItemData['StartDateTime'], pos);
|
||||
pos += this.HistoryItemData['StartDateTime'].length;
|
||||
buf.write(this.HistoryItemData['EndDateTime'], pos);
|
||||
pos += this.HistoryItemData['EndDateTime'].length;
|
||||
this.HistoryItemData['VoteInitiator'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.write(this.HistoryItemData['VoteType'], pos);
|
||||
pos += this.HistoryItemData['VoteType'].length;
|
||||
buf.write(this.HistoryItemData['VoteResult'], pos);
|
||||
pos += this.HistoryItemData['VoteResult'].length;
|
||||
buf.writeFloatLE(this.HistoryItemData['Majority'], pos);
|
||||
pos += 4;
|
||||
buf.writeInt32LE(this.HistoryItemData['Quorum'], pos);
|
||||
pos += 4;
|
||||
buf.write(this.HistoryItemData['ProposalText'], pos);
|
||||
pos += this.HistoryItemData['ProposalText'].length;
|
||||
const count = this.VoteItem.length;
|
||||
buf.writeUInt8(this.VoteItem.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
this.VoteItem[i]['CandidateID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.write(this.VoteItem[i]['VoteCast'], pos);
|
||||
pos += this.VoteItem[i]['VoteCast'].length;
|
||||
buf.writeInt32LE(this.VoteItem[i]['NumVotes'], pos);
|
||||
pos += 4;
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjAgentData: {
|
||||
AgentID: UUID,
|
||||
GroupID: UUID
|
||||
} = {
|
||||
AgentID: UUID.zero(),
|
||||
GroupID: UUID.zero()
|
||||
};
|
||||
newObjAgentData['AgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentData['GroupID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentData = newObjAgentData;
|
||||
const newObjTransactionData: {
|
||||
TransactionID: UUID,
|
||||
TotalNumItems: number
|
||||
} = {
|
||||
TransactionID: UUID.zero(),
|
||||
TotalNumItems: 0
|
||||
};
|
||||
newObjTransactionData['TransactionID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjTransactionData['TotalNumItems'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
this.TransactionData = newObjTransactionData;
|
||||
const newObjHistoryItemData: {
|
||||
VoteID: UUID,
|
||||
TerseDateID: string,
|
||||
StartDateTime: string,
|
||||
EndDateTime: string,
|
||||
VoteInitiator: UUID,
|
||||
VoteType: string,
|
||||
VoteResult: string,
|
||||
Majority: number,
|
||||
Quorum: number,
|
||||
ProposalText: string
|
||||
} = {
|
||||
VoteID: UUID.zero(),
|
||||
TerseDateID: '',
|
||||
StartDateTime: '',
|
||||
EndDateTime: '',
|
||||
VoteInitiator: UUID.zero(),
|
||||
VoteType: '',
|
||||
VoteResult: '',
|
||||
Majority: 0,
|
||||
Quorum: 0,
|
||||
ProposalText: ''
|
||||
};
|
||||
newObjHistoryItemData['VoteID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjHistoryItemData['TerseDateID'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjHistoryItemData['StartDateTime'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjHistoryItemData['EndDateTime'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjHistoryItemData['VoteInitiator'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjHistoryItemData['VoteType'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjHistoryItemData['VoteResult'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjHistoryItemData['Majority'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjHistoryItemData['Quorum'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjHistoryItemData['ProposalText'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
this.HistoryItemData = newObjHistoryItemData;
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.VoteItem = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjVoteItem: {
|
||||
CandidateID: UUID,
|
||||
VoteCast: string,
|
||||
NumVotes: number
|
||||
} = {
|
||||
CandidateID: UUID.zero(),
|
||||
VoteCast: '',
|
||||
NumVotes: 0
|
||||
};
|
||||
newObjVoteItem['CandidateID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjVoteItem['VoteCast'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjVoteItem['NumVotes'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
this.VoteItem.push(newObjVoteItem);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user