mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-23 22:17:31 +00:00
34 lines
618 B
C++
34 lines
618 B
C++
|
#include "ThreadsafePacketLogger.h"
|
||
|
#include <string.h>
|
||
|
|
||
|
ThreadsafePacketLogger::ThreadsafePacketLogger()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
ThreadsafePacketLogger::~ThreadsafePacketLogger()
|
||
|
{
|
||
|
char **msg;
|
||
|
while ((msg = logMessages.ReadLock()) != 0)
|
||
|
{
|
||
|
rakFree((*msg));
|
||
|
}
|
||
|
}
|
||
|
void ThreadsafePacketLogger::Update(RakPeerInterface *peer)
|
||
|
{
|
||
|
(void) peer;
|
||
|
|
||
|
char **msg;
|
||
|
while ((msg = logMessages.ReadLock()) != 0)
|
||
|
{
|
||
|
WriteLog(*msg);
|
||
|
rakFree((*msg));
|
||
|
}
|
||
|
}
|
||
|
void ThreadsafePacketLogger::AddToLog(const char *str)
|
||
|
{
|
||
|
char **msg = logMessages.WriteLock();
|
||
|
*msg = (char*) rakMalloc( strlen(str)+1 );
|
||
|
strcpy(*msg, str);
|
||
|
logMessages.WriteUnlock();
|
||
|
}
|