summaryrefslogtreecommitdiff
path: root/indra/llcorehttp/llwebsocketmgr.cpp
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2025-09-17 13:14:23 -0700
committerRider Linden <rider@lindenlab.com>2025-10-07 09:19:37 -0700
commit684af8426b36f9ad4c2324ae0c5b4dc62f840079 (patch)
treeadd9042ebd25157bb248fb36628cb69494af1c17 /indra/llcorehttp/llwebsocketmgr.cpp
parentf31c194b8674df295edf74693a2f843ca314ca92 (diff)
initial Lua types files, and switch websocket server to use a single connection for all scripts.
Diffstat (limited to 'indra/llcorehttp/llwebsocketmgr.cpp')
-rw-r--r--indra/llcorehttp/llwebsocketmgr.cpp31
1 files changed, 31 insertions, 0 deletions
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<connection_state_t>(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;
+}