mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
Every server now splits its packet counts by peer: its own connections (players on auth and worlds), its master link, or other servers (the worlds on chat, every server on master, a world's chat link, which is now counted too). HTTP requests carrying X-Darkflame-Server count as another server's, the dashboard counts its own requests to the UGC server, and each HTTP client address is counted. The report also gets each RakNet connection's statistics (worlds name the player on it), trimmed to the 32 busiest with the rest summed. Counting stays on the main loop, except the dashboard's UGC fetches, which only touch the locked recorder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
879 B
C++
21 lines
879 B
C++
#include "ChatServerLink.h"
|
|
|
|
#include "BitStream.h"
|
|
#include "BitStreamUtils.h"
|
|
#include "Game.h"
|
|
#include "RakPeerInterface.h"
|
|
#include "TrafficStats.h"
|
|
|
|
void ChatServerLink::Send(const LUBitStream& msg, const PacketPriority priority, const PacketReliability reliability) {
|
|
if (!Game::chatServer) return;
|
|
RakNet::BitStream bitStream;
|
|
msg.WritePacket(bitStream);
|
|
const auto bytes = bitStream.GetNumberOfBytesUsed();
|
|
TrafficStats::Local().Packet(TrafficStats::Now(), TrafficStats::KeyOf(bitStream.GetData(), bytes, true), bytes, 1, TrafficStats::Peer::SERVERS);
|
|
Game::chatServer->Send(&bitStream, priority, reliability, 0, Game::chatSysAddr, false);
|
|
}
|
|
|
|
void ChatServerLink::CountReceived(const unsigned char* data, unsigned int length) {
|
|
TrafficStats::Local().Packet(TrafficStats::Now(), TrafficStats::KeyOf(data, length, false), length, 1, TrafficStats::Peer::SERVERS);
|
|
}
|