diff options
| author | Rider Linden <rider@lindenlab.com> | 2025-08-26 21:29:41 -0700 |
|---|---|---|
| committer | Rider Linden <rider@lindenlab.com> | 2025-10-07 09:19:36 -0700 |
| commit | f31c194b8674df295edf74693a2f843ca314ca92 (patch) | |
| tree | 936a587328d122e0bd12f811a2c310d23ec872b8 /indra/newview/llpreviewscript.cpp | |
| parent | 7b174ab2a7c54d3e25a56530a2179848db2d46c0 (diff) | |
Expand the websocket implementation a bit. Added JSONRPC specialization.
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
| -rw-r--r-- | indra/newview/llpreviewscript.cpp | 71 |
1 files changed, 49 insertions, 22 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 9b2a149212..3ab2e747ea 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -1144,28 +1144,7 @@ void LLScriptEdCore::openInExternalEditor() // Start watching file changes. mContainer->mLiveFile = new LLLiveLSLFile(filename, boost::bind(&LLScriptEdContainer::onExternalChange, mContainer, _1)); mContainer->mLiveFile->addToEventTimer(); - - // if the user has enabled websockets, create the server to talk to the external editor - { - // TODO: Get the name, port, and locality from settings - std::string server_name(LLScriptEditorWSServer::DEFAULT_SERVER_NAME); - U16 server_port(LLScriptEditorWSServer::DEFAULT_SERVER_PORT); - bool server_localhost(true); - - LLWebsocketMgr& wsmgr = LLWebsocketMgr::instance(); - LLScriptEditorWSServer::ptr_t server = - std::static_pointer_cast<LLScriptEditorWSServer>(wsmgr.findServerByName(server_name)); - - if (!server) - { - server = std::make_shared<LLScriptEditorWSServer>(server_name, server_port, server_localhost); - wsmgr.addServer(server); - wsmgr.startServer(server_name); - } - - std::string script_id_hash_str(mContainer->getUniqueHash()); - server->associateEditor(getHandle(), script_id_hash_str); - } + mContainer->startWebsocketServer(); // Open it in external editor. { @@ -1687,6 +1666,54 @@ bool LLScriptEdContainer::handleKeyHere(KEY key, MASK mask) return true; } +void LLScriptEdContainer::startWebsocketServer() +{ + // if the user has enabled websockets, create the server to talk to the external editor + { + // TODO: Get the name, port, and locality from settings + std::string server_name(LLScriptEditorWSServer::DEFAULT_SERVER_NAME); + U16 server_port(LLScriptEditorWSServer::DEFAULT_SERVER_PORT); + bool server_localhost(true); + + LLWebsocketMgr& wsmgr = LLWebsocketMgr::instance(); + LLScriptEditorWSServer::ptr_t server = std::static_pointer_cast<LLScriptEditorWSServer>(wsmgr.findServerByName(server_name)); + + if (!server) + { + server = std::make_shared<LLScriptEditorWSServer>(server_name, server_port, server_localhost); + wsmgr.addServer(server); + wsmgr.startServer(server_name); + } + + std::string script_id_hash_str(getUniqueHash()); + server->associateEditor(getHandle(), script_id_hash_str); + } +} + +void LLScriptEdContainer::attachToWebSocket(const std::shared_ptr<LLScriptEditorWSConnection>& connection) +{ + mWebSocket = connection; +} + +void LLScriptEdContainer::detachFromWebSocket(bool send_disconnect) +{ + if (mWebSocket) + { + if (send_disconnect) + { + // TODO: + mWebSocket->sendDisconnect(LLScriptEditorWSConnection::REASON_EDITOR_CLOSED); + mWebSocket->closeConnection(); + } + mWebSocket.reset(); + } +} + +void LLScriptEdContainer::cleanupWebSocket() +{ + mWebSocket.reset(); +} + /// --------------------------------------------------------------------------- /// LLPreviewLSL /// --------------------------------------------------------------------------- |
