mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
base: Add WebSocketSession
This commit is contained in:
parent
c4b27ed340
commit
fb22b31612
82
src/WebSocketSession.cpp
Normal file
82
src/WebSocketSession.cpp
Normal file
@ -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);
|
||||
}
|
41
src/WebSocketSession.h
Normal file
41
src/WebSocketSession.h
Normal file
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#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<uint64_t> incomingMessages;
|
||||
std::atomic<uint64_t> outgoingMessages;
|
||||
std::atomic<uint8_t> rpcVersion;
|
||||
std::atomic<bool> isIdentified;
|
||||
std::atomic<bool> ignoreInvalidMessages;
|
||||
std::atomic<bool> ignoreNonFatalRequestChecks;
|
||||
std::atomic<uint64_t> eventSubscriptions;
|
||||
};
|
Loading…
Reference in New Issue
Block a user