Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CUserReporterWorker Class Reference

Public Member Functions

 CUserReporterWorker (const std::string &userID, const std::string &url)
 
 ~CUserReporterWorker ()
 
void SetEnabled (bool enabled)
 Called by main thread, when the online reporting is enabled/disabled. More...
 
bool Shutdown ()
 Called by main thread to request shutdown. More...
 
std::string GetStatus ()
 Called by main thread to determine the current status of the uploader. More...
 
void Submit (const std::shared_ptr< CUserReport > &report)
 Called by main thread to add a new report to the queue. More...
 
void Update ()
 Called by the main thread every frame, so we can check retransmission timers. More...
 

Private Member Functions

void Run ()
 
bool GetEnabled ()
 
bool GetShutdown ()
 
void SetStatus (const std::string &status)
 
bool ProcessReport ()
 
void ConstructRequestData (const CUserReport &report)
 
void AppendEscaped (std::string &buffer, const std::string &str)
 

Static Private Member Functions

static void RunThread (CUserReporterWorker *data)
 
static size_t ReceiveCallback (void *buffer, size_t size, size_t nmemb, void *userp)
 
static size_t SendCallback (char *bufptr, size_t size, size_t nmemb, void *userp)
 

Private Attributes

std::thread m_WorkerThread
 
std::mutex m_WorkerMutex
 
std::condition_variable m_WorkerCV
 
std::deque< std::shared_ptr< CUserReport > > m_ReportQueue
 
bool m_Enabled
 
bool m_Shutdown
 
std::string m_Status
 
std::string m_URL
 
std::string m_UserID
 
CURL * m_Curl
 
curl_slist * m_Headers
 
double m_PauseUntilTime
 
std::string m_ResponseData
 
std::string m_RequestData
 
size_t m_RequestDataOffset
 
char m_ErrorBuffer [CURL_ERROR_SIZE]
 
double m_LastUpdateTime
 

Constructor & Destructor Documentation

◆ CUserReporterWorker()

CUserReporterWorker::CUserReporterWorker ( const std::string &  userID,
const std::string &  url 
)
inline

◆ ~CUserReporterWorker()

CUserReporterWorker::~CUserReporterWorker ( )
inline

Member Function Documentation

◆ AppendEscaped()

void CUserReporterWorker::AppendEscaped ( std::string &  buffer,
const std::string &  str 
)
inlineprivate

◆ ConstructRequestData()

void CUserReporterWorker::ConstructRequestData ( const CUserReport report)
inlineprivate

◆ GetEnabled()

bool CUserReporterWorker::GetEnabled ( )
inlineprivate

◆ GetShutdown()

bool CUserReporterWorker::GetShutdown ( )
inlineprivate

◆ GetStatus()

std::string CUserReporterWorker::GetStatus ( )
inline

Called by main thread to determine the current status of the uploader.

◆ ProcessReport()

bool CUserReporterWorker::ProcessReport ( )
inlineprivate

◆ ReceiveCallback()

static size_t CUserReporterWorker::ReceiveCallback ( void *  buffer,
size_t  size,
size_t  nmemb,
void *  userp 
)
inlinestaticprivate

◆ Run()

void CUserReporterWorker::Run ( )
inlineprivate

◆ RunThread()

static void CUserReporterWorker::RunThread ( CUserReporterWorker data)
inlinestaticprivate

◆ SendCallback()

static size_t CUserReporterWorker::SendCallback ( char *  bufptr,
size_t  size,
size_t  nmemb,
void *  userp 
)
inlinestaticprivate

◆ SetEnabled()

void CUserReporterWorker::SetEnabled ( bool  enabled)
inline

Called by main thread, when the online reporting is enabled/disabled.

◆ SetStatus()

void CUserReporterWorker::SetStatus ( const std::string &  status)
inlineprivate

◆ Shutdown()

bool CUserReporterWorker::Shutdown ( )
inline

Called by main thread to request shutdown.

Returns true if we've shut down successfully. Returns false if shutdown is taking too long (we might be blocked on a sync network operation) - you mustn't destroy this object, just leak it and terminate.

◆ Submit()

void CUserReporterWorker::Submit ( const std::shared_ptr< CUserReport > &  report)
inline

Called by main thread to add a new report to the queue.

◆ Update()

void CUserReporterWorker::Update ( )
inline

Called by the main thread every frame, so we can check retransmission timers.

Member Data Documentation

◆ m_Curl

CURL* CUserReporterWorker::m_Curl
private

◆ m_Enabled

bool CUserReporterWorker::m_Enabled
private

◆ m_ErrorBuffer

char CUserReporterWorker::m_ErrorBuffer[CURL_ERROR_SIZE]
private

◆ m_Headers

curl_slist* CUserReporterWorker::m_Headers
private

◆ m_LastUpdateTime

double CUserReporterWorker::m_LastUpdateTime
private

◆ m_PauseUntilTime

double CUserReporterWorker::m_PauseUntilTime
private

◆ m_ReportQueue

std::deque<std::shared_ptr<CUserReport> > CUserReporterWorker::m_ReportQueue
private

◆ m_RequestData

std::string CUserReporterWorker::m_RequestData
private

◆ m_RequestDataOffset

size_t CUserReporterWorker::m_RequestDataOffset
private

◆ m_ResponseData

std::string CUserReporterWorker::m_ResponseData
private

◆ m_Shutdown

bool CUserReporterWorker::m_Shutdown
private

◆ m_Status

std::string CUserReporterWorker::m_Status
private

◆ m_URL

std::string CUserReporterWorker::m_URL
private

◆ m_UserID

std::string CUserReporterWorker::m_UserID
private

◆ m_WorkerCV

std::condition_variable CUserReporterWorker::m_WorkerCV
private

◆ m_WorkerMutex

std::mutex CUserReporterWorker::m_WorkerMutex
private

◆ m_WorkerThread

std::thread CUserReporterWorker::m_WorkerThread
private

The documentation for this class was generated from the following file: