aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llmessagelog.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llmessage/llmessagelog.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llmessagelog.cpp b/linden/indra/llmessage/llmessagelog.cpp
new file mode 100644
index 0000000..965b8c0
--- /dev/null
+++ b/linden/indra/llmessage/llmessagelog.cpp
@@ -0,0 +1,54 @@
1// <edit>
2#include "llmessagelog.h"
3
4LLMessageLogEntry::LLMessageLogEntry(EType type, LLHost from_host, LLHost to_host, U8* data, S32 data_size)
5: mType(type),
6 mFromHost(from_host),
7 mToHost(to_host),
8 mDataSize(data_size)
9{
10 if(data)
11 {
12 mData.resize(data_size);
13 memcpy(&(mData[0]), data, data_size);
14 }
15}
16LLMessageLogEntry::LLMessageLogEntry(EType type, LLHost from_host, LLHost to_host, std::vector<U8> data, S32 data_size)
17: mType(type),
18 mFromHost(from_host),
19 mToHost(to_host),
20 mDataSize(data_size),
21 mData(data)
22{
23}
24LLMessageLogEntry::~LLMessageLogEntry()
25{
26}
27U32 LLMessageLog::sMaxSize = 4096; // testzone fixme todo boom
28std::deque<LLMessageLogEntry> LLMessageLog::sDeque;
29void (*(LLMessageLog::sCallback))(LLMessageLogEntry);
30void LLMessageLog::setMaxSize(U32 size)
31{
32 sMaxSize = size;
33 while(sDeque.size() > sMaxSize)
34 sDeque.pop_front();
35}
36void LLMessageLog::setCallback(void (*callback)(LLMessageLogEntry))
37{
38 sCallback = callback;
39}
40void LLMessageLog::log(LLHost from_host, LLHost to_host, U8* data, S32 data_size)
41{
42 LLMessageLogEntry entry = LLMessageLogEntry(LLMessageLogEntry::TEMPLATE, from_host, to_host, data, data_size);
43 if(!entry.mDataSize || !entry.mData.size()) return;
44 if(sCallback) sCallback(entry);
45 if(!sMaxSize) return;
46 sDeque.push_back(entry);
47 if(sDeque.size() > sMaxSize)
48 sDeque.pop_front();
49}
50std::deque<LLMessageLogEntry> LLMessageLog::getDeque()
51{
52 return sDeque;
53}
54// </edit>