VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
webLVCHelpers.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2026 MAK Technologies, Inc.
3  * All rights reserved.
4  ******************************************************************************/
5 
6 #pragma once
7 
8 #include <oatpp-websocket/WebSocket.hpp>
9 #include <json/json.h>
10 #include <tbb/mutex.h>
11 #include <exception>
12 #include "webLVCClientSession.h"
13 
17 inline bool DtWebLvcSendJson(
18  const oatpp::websocket::WebSocket& conn,
19  DtWebLvcClientSession& session,
20  const Json::Value& msg)
21 {
22  Json::StreamWriterBuilder builder;
23  builder["indentation"] = "";
24  const std::string text = Json::writeString(builder, msg);
25 
26  try
27  {
28  conn.sendOneFrameText(text.c_str());
29  }
30  catch (const std::exception& e)
31  {
33  session.connected = false;
34  session.addLog(std::string("WebSocket send failed: ") + e.what());
35  return false;
36  }
37  catch (...)
38  {
40  session.connected = false;
41  session.addLog("WebSocket send failed: unknown exception");
42  return false;
43  }
44 
46  session.messagesSent++;
47  session.bytesSent += text.size();
48  return true;
49 }
uint64_t messagesSent
Definition: webLVCClientSession.h:195
tbb::mutex mutex
Definition: webLVCClientSession.h:31
bool DtWebLvcSendJson(const oatpp::websocket::WebSocket &conn, DtWebLvcClientSession &session, const Json::Value &msg)
Serialize msg as compact JSON and deliver it to the WebSocket connection. Increments session...
Definition: webLVCHelpers.h:17
Template around a TBB Mutex lock which adds a tracy marker when the lock is waiting on the mutex...
Definition: tracyLocks.h:12
void addLog(const std::string &message)
Definition: webLVCClientSession.h:209
IMGUI_API void Value(const char *prefix, bool b)
uint64_t bytesSent
Definition: webLVCClientSession.h:197
bool connected
Definition: webLVCClientSession.h:34
WebLVC Client Session - Tracks state for each connected client per SISO-STD-017-2022 Section 5...
Definition: webLVCClientSession.h:28

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)