Latest packet handling, parsing, enums, generators, etc..

This commit is contained in:
Casper Warden
2017-11-24 17:45:34 +00:00
parent ec300e33ac
commit 261f28698a
496 changed files with 30448 additions and 57 deletions

View File

@@ -23,4 +23,56 @@ export class TestMessagePacket implements Packet
return 52;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
buf.writeUInt32LE(this.TestBlock1['Test1'], pos);
pos += 4;
const count = 4;
for (let i = 0; i < count; i++)
{
buf.writeUInt32LE(this.NeighborBlock[i]['Test0'], pos);
pos += 4;
buf.writeUInt32LE(this.NeighborBlock[i]['Test1'], pos);
pos += 4;
buf.writeUInt32LE(this.NeighborBlock[i]['Test2'], pos);
pos += 4;
}
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjTestBlock1: {
Test1: number
} = {
Test1: 0
};
newObjTestBlock1['Test1'] = buf.readUInt32LE(pos);
pos += 4;
this.TestBlock1 = newObjTestBlock1;
const count = 4;
this.NeighborBlock = []; for (let i = 0; i < count; i++)
{
const newObjNeighborBlock: {
Test0: number,
Test1: number,
Test2: number
} = {
Test0: 0,
Test1: 0,
Test2: 0
};
newObjNeighborBlock['Test0'] = buf.readUInt32LE(pos);
pos += 4;
newObjNeighborBlock['Test1'] = buf.readUInt32LE(pos);
pos += 4;
newObjNeighborBlock['Test2'] = buf.readUInt32LE(pos);
pos += 4;
this.NeighborBlock.push(newObjNeighborBlock);
}
return pos - startPos;
}
}