Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user