summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfloaterimnearbychatlistener.cpp11
-rw-r--r--indra/newview/scripts/lua/test_LLChat.lua18
2 files changed, 29 insertions, 0 deletions
diff --git a/indra/newview/llfloaterimnearbychatlistener.cpp b/indra/newview/llfloaterimnearbychatlistener.cpp
index d6dfe42639..e8fb510111 100644
--- a/indra/newview/llfloaterimnearbychatlistener.cpp
+++ b/indra/newview/llfloaterimnearbychatlistener.cpp
@@ -35,6 +35,7 @@
#include "llchat.h"
#include "llviewercontrol.h"
+static const F32 CHAT_THROTTLE_PERIOD = 1.f;
LLFloaterIMNearbyChatListener::LLFloaterIMNearbyChatListener()
: LLEventAPI("LLChatBar",
@@ -52,6 +53,16 @@ LLFloaterIMNearbyChatListener::LLFloaterIMNearbyChatListener()
// "sendChat" command
void LLFloaterIMNearbyChatListener::sendChat(LLSD const & chat_data) const
{
+ static F64 last_throttle_time = 0.0;
+ F64 cur_time = LLTimer::getElapsedSeconds();
+
+ if (cur_time < last_throttle_time + CHAT_THROTTLE_PERIOD)
+ {
+ LL_DEBUGS("LLFloaterIMNearbyChatListener") << "'sendChat' was throttled" << LL_ENDL;
+ return;
+ }
+ last_throttle_time = cur_time;
+
// Extract the data
std::string chat_text = LUA_PREFIX + chat_data["message"].asString();
diff --git a/indra/newview/scripts/lua/test_LLChat.lua b/indra/newview/scripts/lua/test_LLChat.lua
new file mode 100644
index 0000000000..95bd218baa
--- /dev/null
+++ b/indra/newview/scripts/lua/test_LLChat.lua
@@ -0,0 +1,18 @@
+LLChat = require 'LLChat'
+
+function generateRandomWord(length)
+ local alphabet = "abcdefghijklmnopqrstuvwxyz"
+ local word = ""
+ for i = 1, length do
+ local randomIndex = math.random(1, #alphabet)
+ word = word .. alphabet:sub(randomIndex, randomIndex)
+ end
+ return word
+end
+
+local msg = ""
+math.randomseed(os.time())
+for i = 1, math.random(1, 10) do
+ msg = msg .. " ".. generateRandomWord(math.random(1, 8))
+end
+LLChat.sendNearby(msg)