From 684af8426b36f9ad4c2324ae0c5b4dc62f840079 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 17 Sep 2025 13:14:23 -0700 Subject: initial Lua types files, and switch websocket server to use a single connection for all scripts. --- indra/llcorehttp/llwebsocketmgr.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'indra/llcorehttp/llwebsocketmgr.cpp') diff --git a/indra/llcorehttp/llwebsocketmgr.cpp b/indra/llcorehttp/llwebsocketmgr.cpp index d44d5d877d..09eb728500 100644 --- a/indra/llcorehttp/llwebsocketmgr.cpp +++ b/indra/llcorehttp/llwebsocketmgr.cpp @@ -485,6 +485,7 @@ bool LLWebsocketMgr::WSServer::start() LL_INFOS("WebSocket") << "WebSocket server thread exiting for: " << mServerName << LL_ENDL; }); + onStarted(); LL_INFOS("WebSocket") << "Started WebSocket server thread: " << mServerName << LL_ENDL; return true; } @@ -517,6 +518,7 @@ void LLWebsocketMgr::WSServer::stop() mServerThread.join(); LL_INFOS("WebSocket") << "WebSocket server thread joined for: " << mServerName << LL_ENDL; } + onStopped(); } bool LLWebsocketMgr::WSServer::isRunning() const @@ -596,6 +598,20 @@ LLWebsocketMgr::WSConnection::ptr_t LLWebsocketMgr::WSServer::getConnection(cons return nullptr; } +LLWebsocketMgr::connection_state_t LLWebsocketMgr::WSServer::getConnectionState(const connection_h& handle) const +{ + websocketpp::lib::error_code ec; + auto con = mImpl->mServer.get_con_from_hdl(handle, ec); + if (ec) + { + LL_WARNS("WebSocket") << mServerName << " failed to get connection state: " << ec.message() << LL_ENDL; + websocketpp::session::state::value state = websocketpp::session::state::closed; + return connection_closed; + } + return static_cast(con->get_state()); +} + + void LLWebsocketMgr::WSServer::handleOpenConnection(const connection_h& handle) { WSConnection::ptr_t connection; @@ -709,3 +725,18 @@ void LLWebsocketMgr::WSConnection::closeConnection(U16 code, const std::string& LL_WARNS("WebSocket") << "Failed to close connection through server" << LL_ENDL; } } + +bool LLWebsocketMgr::WSConnection::isConnected() const +{ + if (mOwningServer.expired()) + { + return false; + } + + LLWebsocketMgr::WSServer::ptr_t server = mOwningServer.lock(); + if (!server) + { + return false; + } + return server->getConnectionState(mConnectionHandle) == connection_open; +} -- cgit v1.3