summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfloaterimnearbychatlistener.cpp39
-rw-r--r--indra/newview/llfloaterimnearbychatlistener.h7
-rw-r--r--indra/newview/scripts/lua/LLChatListener.lua12
-rw-r--r--indra/newview/scripts/lua/test_LLChatListener.lua3
4 files changed, 10 insertions, 51 deletions
diff --git a/indra/newview/llfloaterimnearbychatlistener.cpp b/indra/newview/llfloaterimnearbychatlistener.cpp
index e61bf5ffc2..0618741cc4 100644
--- a/indra/newview/llfloaterimnearbychatlistener.cpp
+++ b/indra/newview/llfloaterimnearbychatlistener.cpp
@@ -33,7 +33,6 @@
#include "llagent.h"
#include "llchat.h"
-#include "llluamanager.h"
#include "llviewercontrol.h"
#include "stringize.h"
@@ -50,34 +49,6 @@ LLFloaterIMNearbyChatListener::LLFloaterIMNearbyChatListener()
"[\"channel\"] chat channel number [default = 0]\n"
"[\"type\"] chat type \"whisper\", \"normal\", \"shout\" [default = \"normal\"]",
&LLFloaterIMNearbyChatListener::sendChat);
-
- add("listen",
- "Start listening to the Nearby chat, chat messages will be resent to the script event pump",
- &LLFloaterIMNearbyChatListener::listenChat,
- llsd::map("reply", LLSD()));
-
- add("stopListening",
- "Stop listening to the Nearby chat",
- &LLFloaterIMNearbyChatListener::stopListeningChat);
-
- mOutConnection = LLEventPumps::instance().obtain("LLNearbyChat").listen("LLFloaterIMNearbyChatListener", [this](const LLSD &data)
- {
- std::map<std::string, std::string> reply_pumps = mReplyPumps;
- std::map<std::string, std::string> scripts = LLLUAmanager::getScriptNames();
- for (auto &it : reply_pumps)
- {
- //check if listener script is still running
- if (scripts.find(it.first) != scripts.end())
- {
- LLEventPumps::instance().obtain(it.second).post(data);
- }
- else
- {
- mReplyPumps.erase(it.first);
- }
- }
- return false;
- });
}
@@ -132,13 +103,3 @@ void LLFloaterIMNearbyChatListener::sendChat(LLSD const & chat_data)
gSavedSettings.getBOOL("PlayChatAnim"));
}
-
-void LLFloaterIMNearbyChatListener::listenChat(LLSD const &chat_data)
-{
- mReplyPumps[LLCoros::getName()] = chat_data["reply"].asString();
-}
-
-void LLFloaterIMNearbyChatListener::stopListeningChat(LLSD const &chat_data)
-{
- mReplyPumps.erase(LLCoros::getName());
-}
diff --git a/indra/newview/llfloaterimnearbychatlistener.h b/indra/newview/llfloaterimnearbychatlistener.h
index a466db8e5f..18a8bacfaa 100644
--- a/indra/newview/llfloaterimnearbychatlistener.h
+++ b/indra/newview/llfloaterimnearbychatlistener.h
@@ -43,14 +43,7 @@ public:
private:
void sendChat(LLSD const & chat_data);
- void listenChat(LLSD const &chat_data);
- void stopListeningChat(LLSD const &chat_data);
-
F64 mLastThrottleTime{ 0.0 };
-
- LLTempBoundListener mOutConnection;
- std::map<std::string, std::string> mReplyPumps;
-
};
#endif // LL_LLFLOATERIMNEARBYCHATLISTENER_H
diff --git a/indra/newview/scripts/lua/LLChatListener.lua b/indra/newview/scripts/lua/LLChatListener.lua
index d615ae5dbc..b4e90d272c 100644
--- a/indra/newview/scripts/lua/LLChatListener.lua
+++ b/indra/newview/scripts/lua/LLChatListener.lua
@@ -1,8 +1,10 @@
local fiber = require 'fiber'
local inspect = require 'inspect'
+local leap = require 'leap'
local LLChatListener = {}
local waitfor = {}
+local listener_name = {}
function LLChatListener:new()
local obj = setmetatable({}, self)
@@ -13,14 +15,16 @@ function LLChatListener:new()
end
function LLChatListener:handleMessages(event_data)
- --print(inspect(event_data))
+ print(inspect(event_data))
return true
end
function LLChatListener:start()
waitfor = leap.WaitFor:new(-1, self.name)
function waitfor:filter(pump, data)
- return data
+ if pump == "LLNearbyChat" then
+ return data
+ end
end
fiber.launch(self.name, function()
@@ -30,11 +34,11 @@ function LLChatListener:start()
end
end)
- leap.send('LLChatBar', {op='listen'})
+ listener_name = leap.request(leap.cmdpump(), {op='listen', source='LLNearbyChat', listener="ChatListener", tweak=true}).listener
end
function LLChatListener:stop()
- leap.send('LLChatBar', {op='stopListening'})
+ leap.send(leap.cmdpump(), {op='stoplistening', source='LLNearbyChat', listener=listener_name})
waitfor:close()
end
diff --git a/indra/newview/scripts/lua/test_LLChatListener.lua b/indra/newview/scripts/lua/test_LLChatListener.lua
index 2c7b1dc3e5..b9696e7cfc 100644
--- a/indra/newview/scripts/lua/test_LLChatListener.lua
+++ b/indra/newview/scripts/lua/test_LLChatListener.lua
@@ -1,5 +1,6 @@
local LLChatListener = require 'LLChatListener'
local LLChat = require 'LLChat'
+local leap = require 'leap'
function openOrEcho(message)
local floater_name = string.match(message, "^open%s+(%w+)")
@@ -21,7 +22,7 @@ function listener:handleMessages(event_data)
else
openOrEcho(event_data.message)
end
- return LLChatListener.handleMessages(self, event_data)
+ return true
end
listener:start()