mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2026-04-17 18:39:52 +00:00
Statistic reports mainly packets per second
This commit is contained in:
@@ -90,7 +90,7 @@ void GrabRole(Client*c){
|
||||
std::thread t1(HTTP,c);
|
||||
t1.detach();
|
||||
}
|
||||
|
||||
extern int PPS;
|
||||
void GlobalParser(Client*c, const std::string&Packet){
|
||||
if(Packet.empty())return;
|
||||
if(Packet.find("TEST")!=std::string::npos)SyncVehicles(c);
|
||||
@@ -131,10 +131,9 @@ void GlobalParser(Client*c, const std::string&Packet){
|
||||
break;
|
||||
}
|
||||
//V to Z
|
||||
if(Packet.length() > 1000){
|
||||
std::cout << "Received data from: " << c->GetName() << " Size: " << Packet.length() << std::endl;
|
||||
if(Code <= 90 && Code >= 86){
|
||||
PPS++;
|
||||
SendToAll(c,Packet,false,false);
|
||||
}
|
||||
|
||||
if(Code <= 90 && Code >= 86)SendToAll(c,Packet,false,false);
|
||||
if(Debug)debug("Data : " + Packet);
|
||||
if(Debug)debug("Vehicle Data Received from " + c->GetName());
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "Client.hpp"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include <any>
|
||||
|
||||
|
||||
|
||||
33
src/Network 2.0/StatMonitor.cpp
Normal file
33
src/Network 2.0/StatMonitor.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 6/18/2020
|
||||
///
|
||||
#include "Client.hpp"
|
||||
#include <string>
|
||||
#include <thread>
|
||||
std::string StatReport = "-";
|
||||
int PPS = 0;
|
||||
[[noreturn]] void Monitor(){
|
||||
int R,C;
|
||||
while(true){
|
||||
if(Clients.empty()){
|
||||
StatReport = "-";
|
||||
}else{
|
||||
C = 0;
|
||||
for(Client *c : Clients){
|
||||
if(c->GetCarCount() > 0)C++;
|
||||
}
|
||||
if(C == 0 || PPS == 0){
|
||||
StatReport = "-";
|
||||
}else{
|
||||
R = PPS/C;
|
||||
StatReport = std::to_string(R);
|
||||
}
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
}
|
||||
|
||||
void StatInit(){
|
||||
std::thread Init(Monitor);
|
||||
Init.detach();
|
||||
}
|
||||
Reference in New Issue
Block a user