aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/lllogtextmessage.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmessage/lllogtextmessage.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llmessage/lllogtextmessage.cpp')
-rw-r--r--linden/indra/llmessage/lllogtextmessage.cpp118
1 files changed, 118 insertions, 0 deletions
diff --git a/linden/indra/llmessage/lllogtextmessage.cpp b/linden/indra/llmessage/lllogtextmessage.cpp
new file mode 100644
index 0000000..06cc9c8
--- /dev/null
+++ b/linden/indra/llmessage/lllogtextmessage.cpp
@@ -0,0 +1,118 @@
1/**
2 * @file lllogtextmessage.cpp
3 * @author Phoenix
4 * @date 2005-01-12
5 * @brief Impelmentation of the text logger.
6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 *
9 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement
12 * ("Other License"), formally executed by you and Linden Lab. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlife.com/developers/opensource/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlife.com/developers/opensource/flossexception
20 *
21 * By copying, modifying or distributing this software, you acknowledge
22 * that you have read and understood your obligations described above,
23 * and agree to abide by those obligations.
24 *
25 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
26 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
27 * COMPLETENESS OR PERFORMANCE.
28 */
29
30#include "linden_common.h"
31#include "lllogtextmessage.h"
32
33#include "message.h"
34
35
36LLLogTextMessage::~LLLogTextMessage()
37{
38 S32 queue_size = (S32)mQueue.size();
39 if(queue_size > 0)
40 {
41 llwarns << "Deleting queus with messages still on it." << llendl;
42 }
43}
44
45void LLLogTextMessage::log(
46 const LLUUID& from,
47 const LLUUID& to,
48 const char* mesg)
49{
50 const F64 F64_ZERO = 0.0;
51 log(from, to, F64_ZERO, F64_ZERO, mesg);
52}
53
54void LLLogTextMessage::log(
55 const LLUUID& from,
56 F64 global_x,
57 F64 global_y,
58 const char* mesg)
59{
60 log(from, LLUUID::null, global_x, global_y, mesg);
61}
62
63void LLLogTextMessage::log(
64 const LLUUID& from,
65 const LLUUID& to,
66 F64 global_x,
67 F64 global_y,
68 const char* mesg)
69{
70 const S32 OVERHEAD = (2*sizeof(LLUUID))+(2*sizeof(F64))+(sizeof(S32));
71 const U32 MAX_LOGS_PER_MSG = 100;
72 const U32 LOG_MTU = 4000;
73 LLLogTextMessageData data(from, to, global_x, global_y, mesg);
74 mQueue.push_back(data);
75 mPendingSize += (S32)(OVERHEAD + data.mMessage.size());
76 if((mQueue.size() >= MAX_LOGS_PER_MSG) || (mPendingSize > (S32)LOG_MTU))
77 {
78 flush();
79 }
80}
81
82void LLLogTextMessage::flush()
83{
84 mPendingSize = 0;
85 if(mQueue.empty()) return;
86 LLMessageSystem* msg = gMessageSystem;
87 msg->newMessageFast(_PREHASH_LogTextMessage);
88 while(!mQueue.empty())
89 {
90 LLLogTextMessageData data(mQueue.front());
91 mQueue.pop_front();
92 msg->nextBlockFast(_PREHASH_DataBlock);
93 msg->addUUIDFast(_PREHASH_FromAgentId, data.mFromID);
94 msg->addUUIDFast(_PREHASH_ToAgentId, data.mToID);
95 msg->addF64Fast(_PREHASH_GlobalX, data.mGlobalX);
96 msg->addF64Fast(_PREHASH_GlobalY, data.mGlobalY);
97 msg->addU32Fast(_PREHASH_Time, data.mTime);
98 msg->addStringFast(_PREHASH_Message, data.mMessage.c_str());
99 }
100
101 // Try to make this reliable, but don't try too hard
102 msg->sendReliable(mDataserver, 3, TRUE, 0.f, NULL, NULL);
103}
104
105LLLogTextMessage::LLLogTextMessageData::LLLogTextMessageData(
106 const LLUUID& from,
107 const LLUUID& to,
108 const F64& global_x,
109 const F64& gloabl_y,
110 const char* message) :
111 mFromID(from),
112 mToID(to),
113 mGlobalX(global_x),
114 mGlobalY(gloabl_y),
115 mMessage(message)
116{
117 mTime = (S32)time(NULL);
118}