From 6d75034e9bf3179be757e4685078fbfe5a529fc3 Mon Sep 17 00:00:00 2001 From: WolfGangS Date: Sun, 21 Dec 2025 15:06:04 +0000 Subject: Add method to script editor websocket to list scripts available for subscription Signed-off-by: WolfGangS --- indra/newview/llscripteditorws.cpp | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'indra/newview/llscripteditorws.cpp') diff --git a/indra/newview/llscripteditorws.cpp b/indra/newview/llscripteditorws.cpp index 814157e86c..3a99b5bb03 100644 --- a/indra/newview/llscripteditorws.cpp +++ b/indra/newview/llscripteditorws.cpp @@ -168,17 +168,14 @@ void LLScriptEditorWSServer::unsubscribeEditor(const std::string &script_id) void LLScriptEditorWSServer::unsubscribeConnection(U32 connection_id) { - for (auto it = mSubscriptions.begin(); it != mSubscriptions.end(); ) + for (auto it = mSubscriptions.begin(); it != mSubscriptions.end(); ++it) { if (it->second.mConnectionID == connection_id) { LL_DEBUGS("ScriptEditorWS") << "Unsubscribing script " << it->first << " from connection ID " << connection_id << LL_ENDL; - it = mSubscriptions.erase(it); - } - else - { - ++it; + it->second.mConnectionID = 0; + it->second.mConnection.reset(); } } } @@ -289,6 +286,16 @@ void LLScriptEditorWSServer::setupConnectionMethods(LLJSONRPCConnection::ptr_t c { // this is a notification, no response expected return LLSD(); }); + script_connection->registerMethod("script.list", + [that, connection_id](const std::string&, const LLSD&, const LLSD& params) -> LLSD + { + auto server = that.lock(); + if (server) + { + return server->handleFileWatcherFileListRequest(); + } + return LLSD(); + }); // script_connection->registerMethod("language.syntax", ) } } @@ -411,6 +418,25 @@ LLSD LLScriptEditorWSServer::handleScriptUnsubscribe(U32 connection_id, const LL return LLSD(); } +LLSD LLScriptEditorWSServer::handleFileWatcherFileListRequest() const +{ + LLSD response; + + response["temp_dir"] = LLFile::tmpdir(); + + // Add array of script_id's from active scripts + LLSD script_ids_array = LLSD::emptyArray(); + for (const auto& [script_id, subinfo] : mSubscriptions) + { + script_ids_array.append(script_id); + } + response["script_ids"] = script_ids_array; + + response["success"] = true; + + return response; +} + void LLScriptEditorWSServer::notifyScript(const std::string& script_id, const std::string &method, const LLSD& message) const { auto it = mSubscriptions.find(script_id); -- cgit v1.3 From 3fc4acfd6429531f2e00b36e0784887d755c374f Mon Sep 17 00:00:00 2001 From: WolfGangS Date: Wed, 24 Dec 2025 18:48:01 +0000 Subject: Trailing whitespace Signed-off-by: WolfGangS --- indra/newview/llscripteditorws.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llscripteditorws.cpp') diff --git a/indra/newview/llscripteditorws.cpp b/indra/newview/llscripteditorws.cpp index 3a99b5bb03..582d94e236 100644 --- a/indra/newview/llscripteditorws.cpp +++ b/indra/newview/llscripteditorws.cpp @@ -423,7 +423,7 @@ LLSD LLScriptEditorWSServer::handleFileWatcherFileListRequest() const LLSD response; response["temp_dir"] = LLFile::tmpdir(); - + // Add array of script_id's from active scripts LLSD script_ids_array = LLSD::emptyArray(); for (const auto& [script_id, subinfo] : mSubscriptions) @@ -431,9 +431,9 @@ LLSD LLScriptEditorWSServer::handleFileWatcherFileListRequest() const script_ids_array.append(script_id); } response["script_ids"] = script_ids_array; - + response["success"] = true; - + return response; } -- cgit v1.3 From edd823d420a06b09f2fd802c3b3327e730685430 Mon Sep 17 00:00:00 2001 From: WolfGang Date: Thu, 8 Jan 2026 22:00:46 +0000 Subject: Remove unused connection_id value Co-authored-by: Andrey Lihatskiy <118752495+marchcat@users.noreply.github.com> --- indra/newview/llscripteditorws.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llscripteditorws.cpp') diff --git a/indra/newview/llscripteditorws.cpp b/indra/newview/llscripteditorws.cpp index 582d94e236..30a1ca53f6 100644 --- a/indra/newview/llscripteditorws.cpp +++ b/indra/newview/llscripteditorws.cpp @@ -287,7 +287,7 @@ void LLScriptEditorWSServer::setupConnectionMethods(LLJSONRPCConnection::ptr_t c return LLSD(); }); script_connection->registerMethod("script.list", - [that, connection_id](const std::string&, const LLSD&, const LLSD& params) -> LLSD + [that](const std::string&, const LLSD&, const LLSD& params) -> LLSD { auto server = that.lock(); if (server) -- cgit v1.3