summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2024-08-13 14:01:11 +0300
committerGitHub <noreply@github.com>2024-08-13 14:01:11 +0300
commite363ae54b08842c628970e6d32eb5e6fea635469 (patch)
tree28f68ff0d7ebf3ae20a6233a51d7e7b5ef13fa55 /indra/newview
parentbc7254c0029d730e891eb05a257c8af034db10ec (diff)
parent153b0573cd91361a0f674c0ce1b9d7cb47e2bbc0 (diff)
Merge pull request #2265 from secondlife/lua-groupchat-throttle
Add Throttle and LogThrottle classes to manage throttled APIs.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/groupchatlistener.cpp19
-rw-r--r--indra/newview/groupchatlistener.h4
2 files changed, 11 insertions, 12 deletions
diff --git a/indra/newview/groupchatlistener.cpp b/indra/newview/groupchatlistener.cpp
index 09951ba1cc..298f41ff8c 100644
--- a/indra/newview/groupchatlistener.cpp
+++ b/indra/newview/groupchatlistener.cpp
@@ -43,7 +43,8 @@ static const F32 GROUP_CHAT_THROTTLE_PERIOD = 1.f;
LLGroupChatListener::LLGroupChatListener():
LLEventAPI("GroupChat",
"API to enter, leave, send and intercept group chat messages"),
- mLastThrottleTime(0)
+ mIMThrottle("sendGroupIM", &LLGroupChatListener::sendGroupIM_, this,
+ GROUP_CHAT_THROTTLE_PERIOD)
{
add("startGroupChat",
"Enter a group chat in group with UUID [\"group_id\"]\n"
@@ -101,18 +102,14 @@ void LLGroupChatListener::sendGroupIM(LLSD const &data)
return;
}
- F64 cur_time = LLTimer::getElapsedSeconds();
-
- if (cur_time < mLastThrottleTime + GROUP_CHAT_THROTTLE_PERIOD)
- {
- LL_DEBUGS("LLGroupChatListener") << "'sendGroupIM' was throttled" << LL_ENDL;
- return;
- }
- mLastThrottleTime = cur_time;
+ mIMThrottle(data["group_id"], data["message"]);
+}
- LLUUID group_id(data["group_id"]);
- LLIMModel::sendMessage(LUA_PREFIX + data["message"].asString(),
+void LLGroupChatListener::sendGroupIM_(const LLUUID& group_id, const std::string& message)
+{
+ LLIMModel::sendMessage(LUA_PREFIX + message,
gIMMgr->computeSessionID(IM_SESSION_GROUP_START, group_id),
group_id,
IM_SESSION_SEND);
}
+
diff --git a/indra/newview/groupchatlistener.h b/indra/newview/groupchatlistener.h
index 35afc5766c..a75fecb254 100644
--- a/indra/newview/groupchatlistener.h
+++ b/indra/newview/groupchatlistener.h
@@ -30,6 +30,7 @@
#define LL_LLGROUPCHATLISTENER_H
#include "lleventapi.h"
+#include "throttle.h"
class LLGroupChatListener: public LLEventAPI
{
@@ -40,8 +41,9 @@ private:
void startGroupChat(LLSD const &data);
void leaveGroupChat(LLSD const &data);
void sendGroupIM(LLSD const &data);
+ void sendGroupIM_(const LLUUID& group_id, const std::string& message);
- F64 mLastThrottleTime {0.0};
+ LogThrottle<LLError::LEVEL_DEBUG, void(const LLUUID&, const std::string&)> mIMThrottle;
};
#endif /* ! defined(LL_LLGROUPCHATLISTENER_H) */