Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -23,4 +23,44 @@ export class SendXferPacketPacket implements Packet
|
||||
return (this.DataPacket['Data'].length + 2) + 12;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
buf.writeInt32LE(this.XferID['ID'].low, pos);
|
||||
pos += 4;
|
||||
buf.writeInt32LE(this.XferID['ID'].high, pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.XferID['Packet'], pos);
|
||||
pos += 4;
|
||||
buf.write(this.DataPacket['Data'], pos);
|
||||
pos += this.DataPacket['Data'].length;
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjXferID: {
|
||||
ID: Long,
|
||||
Packet: number
|
||||
} = {
|
||||
ID: Long.ZERO,
|
||||
Packet: 0
|
||||
};
|
||||
newObjXferID['ID'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
|
||||
pos += 8;
|
||||
newObjXferID['Packet'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
this.XferID = newObjXferID;
|
||||
const newObjDataPacket: {
|
||||
Data: string
|
||||
} = {
|
||||
Data: ''
|
||||
};
|
||||
newObjDataPacket['Data'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
this.DataPacket = newObjDataPacket;
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user