diff options
| author | WolfGangS <flamin2k8@gmail.com> | 2025-12-21 15:06:04 +0000 |
|---|---|---|
| committer | WolfGangS <flamin2k8@gmail.com> | 2025-12-21 15:06:04 +0000 |
| commit | 6d75034e9bf3179be757e4685078fbfe5a529fc3 (patch) | |
| tree | 440e1341b681e71059376d59ca730b15e233d37d /indra/newview/llscripteditorws.cpp | |
| parent | 9f9df3e55e4994cc2942a8e19c267b793e61cfb1 (diff) | |
Add method to script editor websocket to list scripts available for subscription
Signed-off-by: WolfGangS <flamin2k8@gmail.com>
Diffstat (limited to 'indra/newview/llscripteditorws.cpp')
| -rw-r--r-- | indra/newview/llscripteditorws.cpp | 38 |
1 files changed, 32 insertions, 6 deletions
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); |
