mirror of
https://github.com/EQEmu/Server.git
synced 2026-07-06 13:07:17 +00:00
Integrating protobuffers
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
SET(service_sources
|
||||
test2_service.cpp
|
||||
)
|
||||
|
||||
SET(service_headers
|
||||
test2_service.h
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(test2_service ${service_sources} ${service_headers})
|
||||
|
||||
INSTALL(TARGETS test2_service RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
|
||||
TARGET_LINK_LIBRARIES(test2_service ${SERVER_LIBS})
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "test2_service.h"
|
||||
#include "../../common/eqemu_logsys.h"
|
||||
#include "../../common/eqemu_config.h"
|
||||
|
||||
EQ::Test2Service::Test2Service()
|
||||
: EQ::Service("Test2", 3000, 1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
EQ::Test2Service::~Test2Service() {
|
||||
|
||||
}
|
||||
|
||||
void EQ::Test2Service::OnStart() {
|
||||
bytes = 0;
|
||||
packets = 0;
|
||||
}
|
||||
|
||||
void EQ::Test2Service::OnStop() {
|
||||
}
|
||||
|
||||
void EQ::Test2Service::OnHeartbeat(double time_since_last) {
|
||||
|
||||
auto bytes_per_sec = bytes / time_since_last;
|
||||
auto packets_per_sec = packets / time_since_last;
|
||||
printf("Transfer rate %.2f KB/sec %.2f Packets/sec\n", bytes_per_sec / 1000.0, packets_per_sec);
|
||||
|
||||
bytes = 0;
|
||||
packets = 0;
|
||||
}
|
||||
|
||||
void EQ::Test2Service::OnRoutedMessage(const std::string& filter, const std::string& identifier, const std::string& id, const EQ::Net::Packet& payload)
|
||||
{
|
||||
bytes += sizeof(RouteToMessage);
|
||||
bytes += payload.Length();
|
||||
packets++;
|
||||
}
|
||||
|
||||
EQRegisterService(EQ::Test2Service);
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../common/service.h"
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
class Test2Service : public EQ::Service
|
||||
{
|
||||
public:
|
||||
Test2Service();
|
||||
virtual ~Test2Service();
|
||||
|
||||
protected:
|
||||
virtual void OnStart();
|
||||
virtual void OnStop();
|
||||
virtual void OnHeartbeat(double time_since_last);
|
||||
virtual void OnRoutedMessage(const std::string& filter, const std::string& identifier, const std::string& id, const EQ::Net::Packet& payload);
|
||||
|
||||
private:
|
||||
size_t bytes;
|
||||
size_t packets;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user