diff options
| author | Andrey Lihatskiy <118752495+marchcat@users.noreply.github.com> | 2026-01-09 00:47:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-09 00:47:13 +0200 |
| commit | 0d846fe32411f06ffe63082b0b63499dbdff967c (patch) | |
| tree | b53c904c20b3ecb195bc0878f7a88c1543c3b890 | |
| parent | 4b0cc023a668d2376fd77396ddc79b6ec595b8b5 (diff) | |
| parent | edd823d420a06b09f2fd802c3b3327e730685430 (diff) | |
Merge pull request #5182 from WolfGangS/wolfgang/lua_editor/ws_script_list
Add method to script editor websocket that lists scripts available for subscription
| -rw-r--r-- | indra/newview/llscripteditorws.cpp | 38 | ||||
| -rw-r--r-- | indra/newview/llscripteditorws.h | 1 |
2 files changed, 33 insertions, 6 deletions
diff --git a/indra/newview/llscripteditorws.cpp b/indra/newview/llscripteditorws.cpp index 814157e86c..30a1ca53f6 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](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); diff --git a/indra/newview/llscripteditorws.h b/indra/newview/llscripteditorws.h index 1c8745001b..c8898c66a7 100644 --- a/indra/newview/llscripteditorws.h +++ b/indra/newview/llscripteditorws.h @@ -194,6 +194,7 @@ protected: LLSD handleSyntaxRequest(const LLSD ¶ms) const; LLSD handleScriptSubscribe(U32 connection_id, const LLSD& params); LLSD handleScriptUnsubscribe(U32 connection_id, const LLSD& params); + LLSD handleFileWatcherFileListRequest() const; private: struct EditorSubscription |
