Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -57,4 +57,232 @@ export class ViewerStatsPacket implements Packet
|
||||
return (this.AgentData['SysOS'].length + 1 + this.AgentData['SysCPU'].length + 1 + this.AgentData['SysGPU'].length + 1) + ((12) * this.MiscStats.length) + 142;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
this.AgentData['AgentID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentData['SessionID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentData['IP'].writeToBuffer(buf, pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.AgentData['StartTime'], pos);
|
||||
pos += 4;
|
||||
buf.writeFloatLE(this.AgentData['RunTime'], pos);
|
||||
pos += 4;
|
||||
buf.writeFloatLE(this.AgentData['SimFPS'], pos);
|
||||
pos += 4;
|
||||
buf.writeFloatLE(this.AgentData['FPS'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt8(this.AgentData['AgentsInView'], pos++);
|
||||
buf.writeFloatLE(this.AgentData['Ping'], pos);
|
||||
pos += 4;
|
||||
buf.writeDoubleLE(this.AgentData['MetersTraveled'], pos);
|
||||
pos += 8;
|
||||
buf.writeInt32LE(this.AgentData['RegionsVisited'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.AgentData['SysRAM'], pos);
|
||||
pos += 4;
|
||||
buf.write(this.AgentData['SysOS'], pos);
|
||||
pos += this.AgentData['SysOS'].length;
|
||||
buf.write(this.AgentData['SysCPU'], pos);
|
||||
pos += this.AgentData['SysCPU'].length;
|
||||
buf.write(this.AgentData['SysGPU'], pos);
|
||||
pos += this.AgentData['SysGPU'].length;
|
||||
buf.writeUInt32LE(this.DownloadTotals['World'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.DownloadTotals['Objects'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.DownloadTotals['Textures'], pos);
|
||||
pos += 4;
|
||||
let count = 2;
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
buf.writeUInt32LE(this.NetStats[i]['Bytes'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.NetStats[i]['Packets'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.NetStats[i]['Compressed'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.NetStats[i]['Savings'], pos);
|
||||
pos += 4;
|
||||
}
|
||||
buf.writeUInt32LE(this.FailStats['SendPacket'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.FailStats['Dropped'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.FailStats['Resent'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.FailStats['FailedResends'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.FailStats['OffCircuit'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.FailStats['Invalid'], pos);
|
||||
pos += 4;
|
||||
count = this.MiscStats.length;
|
||||
buf.writeUInt8(this.MiscStats.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
buf.writeUInt32LE(this.MiscStats[i]['Type'], pos);
|
||||
pos += 4;
|
||||
buf.writeDoubleLE(this.MiscStats[i]['Value'], pos);
|
||||
pos += 8;
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjAgentData: {
|
||||
AgentID: UUID,
|
||||
SessionID: UUID,
|
||||
IP: IPAddress,
|
||||
StartTime: number,
|
||||
RunTime: number,
|
||||
SimFPS: number,
|
||||
FPS: number,
|
||||
AgentsInView: number,
|
||||
Ping: number,
|
||||
MetersTraveled: number,
|
||||
RegionsVisited: number,
|
||||
SysRAM: number,
|
||||
SysOS: string,
|
||||
SysCPU: string,
|
||||
SysGPU: string
|
||||
} = {
|
||||
AgentID: UUID.zero(),
|
||||
SessionID: UUID.zero(),
|
||||
IP: IPAddress.zero(),
|
||||
StartTime: 0,
|
||||
RunTime: 0,
|
||||
SimFPS: 0,
|
||||
FPS: 0,
|
||||
AgentsInView: 0,
|
||||
Ping: 0,
|
||||
MetersTraveled: 0,
|
||||
RegionsVisited: 0,
|
||||
SysRAM: 0,
|
||||
SysOS: '',
|
||||
SysCPU: '',
|
||||
SysGPU: ''
|
||||
};
|
||||
newObjAgentData['AgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentData['SessionID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentData['IP'] = new IPAddress(buf, pos);
|
||||
pos += 4;
|
||||
newObjAgentData['StartTime'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjAgentData['RunTime'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjAgentData['SimFPS'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjAgentData['FPS'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjAgentData['AgentsInView'] = buf.readUInt8(pos++);
|
||||
newObjAgentData['Ping'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjAgentData['MetersTraveled'] = buf.readDoubleLE(pos);
|
||||
pos += 8;
|
||||
newObjAgentData['RegionsVisited'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjAgentData['SysRAM'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjAgentData['SysOS'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjAgentData['SysCPU'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjAgentData['SysGPU'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
this.AgentData = newObjAgentData;
|
||||
const newObjDownloadTotals: {
|
||||
World: number,
|
||||
Objects: number,
|
||||
Textures: number
|
||||
} = {
|
||||
World: 0,
|
||||
Objects: 0,
|
||||
Textures: 0
|
||||
};
|
||||
newObjDownloadTotals['World'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjDownloadTotals['Objects'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjDownloadTotals['Textures'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
this.DownloadTotals = newObjDownloadTotals;
|
||||
let count = 2;
|
||||
this.NetStats = []; for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjNetStats: {
|
||||
Bytes: number,
|
||||
Packets: number,
|
||||
Compressed: number,
|
||||
Savings: number
|
||||
} = {
|
||||
Bytes: 0,
|
||||
Packets: 0,
|
||||
Compressed: 0,
|
||||
Savings: 0
|
||||
};
|
||||
newObjNetStats['Bytes'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjNetStats['Packets'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjNetStats['Compressed'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjNetStats['Savings'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
this.NetStats.push(newObjNetStats);
|
||||
}
|
||||
const newObjFailStats: {
|
||||
SendPacket: number,
|
||||
Dropped: number,
|
||||
Resent: number,
|
||||
FailedResends: number,
|
||||
OffCircuit: number,
|
||||
Invalid: number
|
||||
} = {
|
||||
SendPacket: 0,
|
||||
Dropped: 0,
|
||||
Resent: 0,
|
||||
FailedResends: 0,
|
||||
OffCircuit: 0,
|
||||
Invalid: 0
|
||||
};
|
||||
newObjFailStats['SendPacket'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjFailStats['Dropped'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjFailStats['Resent'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjFailStats['FailedResends'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjFailStats['OffCircuit'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjFailStats['Invalid'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
this.FailStats = newObjFailStats;
|
||||
count = buf.readUInt8(pos++);
|
||||
this.MiscStats = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjMiscStats: {
|
||||
Type: number,
|
||||
Value: number
|
||||
} = {
|
||||
Type: 0,
|
||||
Value: 0
|
||||
};
|
||||
newObjMiscStats['Type'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjMiscStats['Value'] = buf.readDoubleLE(pos);
|
||||
pos += 8;
|
||||
this.MiscStats.push(newObjMiscStats);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user