diff options
| author | Rider Linden <rider@lindenlab.com> | 2025-08-24 21:16:36 -0700 |
|---|---|---|
| committer | Rider Linden <rider@lindenlab.com> | 2025-10-07 09:19:34 -0700 |
| commit | 7b174ab2a7c54d3e25a56530a2179848db2d46c0 (patch) | |
| tree | ed45d05732a78f0e2cec5ad2f74dcf6d14ba22e7 /indra/llcorehttp/llwebsocketmgr.cpp | |
| parent | de65dbfcaf4a4f9d3083f014caa1fe2294952e7b (diff) | |
First pass at websocket server for editing.
Diffstat (limited to 'indra/llcorehttp/llwebsocketmgr.cpp')
| -rw-r--r-- | indra/llcorehttp/llwebsocketmgr.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/indra/llcorehttp/llwebsocketmgr.cpp b/indra/llcorehttp/llwebsocketmgr.cpp index 0427bdab54..3e4262b49b 100644 --- a/indra/llcorehttp/llwebsocketmgr.cpp +++ b/indra/llcorehttp/llwebsocketmgr.cpp @@ -30,6 +30,7 @@ #include "llerror.h" #include "llsdserialize.h" #include "llhost.h" +#include "llsdjson.h" #include <websocketpp/config/boost_config.hpp> #include <websocketpp/config/asio_no_tls.hpp> @@ -242,14 +243,16 @@ struct Server_impl */ bool start() { - if (!mServer.stopped()) - { - LL_WARNS("WebSocket") << "WebSocket server is already running" << LL_ENDL; - return false; - } + //if (!mServer.stopped()) + //{ + // LL_WARNS("WebSocket") << "WebSocket server is already running" << LL_ENDL; + // return false; + //} try { + LL_INFOS("WebSocket") << "Starting WebSocket server on port " << mPort + << (mLocalOnly ? " (localhost only)" : " (all interfaces)") << LL_ENDL; mServer.start_accept(); // Run controlled event loop with periodic stop flag checking @@ -592,6 +595,7 @@ void LLWebsocketMgr::WSServer::handleOpenConnection(const connection_h& handle) { LL_WARNS("WebSocket") << mServerName << " failed to create connection object" << LL_ENDL; return; + } // Removed redundant assignment to mConnections[handle] size = mConnections.size(); } @@ -641,7 +645,7 @@ void LLWebsocketMgr::WSServer::handleMessage(const connection_h& handle, const s } //------------------------------------------------------------------------ -bool LLWebsocketMgr::WSConnection::sendMessage(const std::string& message) +bool LLWebsocketMgr::WSConnection::sendMessage(const std::string& message) const { if (!mServer) { @@ -651,6 +655,17 @@ bool LLWebsocketMgr::WSConnection::sendMessage(const std::string& message) return mServer->sendMessageTo(mConnectionHandle, message); } +bool LLWebsocketMgr::WSConnection::sendMessage(const boost::json::value& json) const +{ + std::string message = boost::json::serialize(json); + return sendMessage(message); +} + +bool LLWebsocketMgr::WSConnection::sendMessage(const LLSD& data) const +{ + return sendMessage(LlsdToJson(data)); +} + void LLWebsocketMgr::WSConnection::closeConnection(U16 code, const std::string& reason) { if (!mServer) |
