diff --git a/src/WebSocketSession.cpp b/src/WebSocketSession.cpp new file mode 100644 index 00000000..54ffcff5 --- /dev/null +++ b/src/WebSocketSession.cpp @@ -0,0 +1,82 @@ +#include "WebSocketSession.h" + +WebSocketSession::WebSocketSession() : + incomingMessages(0), + outgoingMessages(0), + rpcVersion(OBS_WEBSOCKET_RPC_VERSION), + isIdentified(false), + ignoreInvalidMessages(false), + ignoreNonFatalRequestChecks(false), + eventSubscriptions(0) +{ +} + +uint64_t WebSocketSession::IncomingMessages() +{ + return incomingMessages.load(); +} + +void WebSocketSession::IncrementIncomingMessages() +{ + incomingMessages++; +} + +uint64_t WebSocketSession::OutgoingMessages() +{ + return outgoingMessages.load(); +} + +void WebSocketSession::IncrementOutgoingMessages() +{ + outgoingMessages++; +} + +uint8_t WebSocketSession::RpcVersion() +{ + return rpcVersion.load(); +} + +void WebSocketSession::SetRpcVersion(uint8_t version) +{ + rpcVersion.store(version); +} + +bool WebSocketSession::IsIdentified() +{ + return isIdentified.load(); +} + +void WebSocketSession::SetIsIdentified(bool identified) +{ + isIdentified.store(identified); +} + +bool WebSocketSession::IgnoreInvalidMessages() +{ + return ignoreInvalidMessages.load(); +} + +void WebSocketSession::SetIgnoreInvalidMessages(bool ignore) +{ + ignoreInvalidMessages.store(ignore); +} + +bool WebSocketSession::IgnoreNonFatalRequestChecks() +{ + return ignoreNonFatalRequestChecks.load(); +} + +void WebSocketSession::SetIgnoreNonFatalRequestChecks(bool ignore) +{ + ignoreNonFatalRequestChecks.store(ignore); +} + +uint64_t WebSocketSession::EventSubscriptions() +{ + return eventSubscriptions.load(); +} + +void WebSocketSession::SetEventSubscriptions(uint64_t subscriptions) +{ + eventSubscriptions.store(subscriptions); +} \ No newline at end of file diff --git a/src/WebSocketSession.h b/src/WebSocketSession.h new file mode 100644 index 00000000..dccf3c2f --- /dev/null +++ b/src/WebSocketSession.h @@ -0,0 +1,41 @@ +#pragma once + +#include + +#include "plugin-macros.generated.h" + +class WebSocketSession +{ + public: + WebSocketSession(); + + uint64_t IncomingMessages(); + void IncrementIncomingMessages(); + + uint64_t OutgoingMessages(); + void IncrementOutgoingMessages(); + + uint8_t RpcVersion(); + void SetRpcVersion(uint8_t version); + + bool IsIdentified(); + void SetIsIdentified(bool identified); + + bool IgnoreInvalidMessages(); + void SetIgnoreInvalidMessages(bool ignore); + + bool IgnoreNonFatalRequestChecks(); + void SetIgnoreNonFatalRequestChecks(bool ignore); + + uint64_t EventSubscriptions(); + void SetEventSubscriptions(uint64_t subscriptions); + + private: + std::atomic incomingMessages; + std::atomic outgoingMessages; + std::atomic rpcVersion; + std::atomic isIdentified; + std::atomic ignoreInvalidMessages; + std::atomic ignoreNonFatalRequestChecks; + std::atomic eventSubscriptions; +}; \ No newline at end of file