WebSocketSession: Add remoteAddress string

This commit is contained in:
tt2468 2021-04-28 11:23:12 -07:00
parent 11913dac76
commit 53e773b1a2
2 changed files with 19 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#include "plugin-macros.generated.h"
WebSocketSession::WebSocketSession() :
_remoteAddress(""),
_connectedAt(0),
_incomingMessages(0),
_outgoingMessages(0),
@ -16,6 +17,19 @@ WebSocketSession::WebSocketSession() :
{
}
std::string WebSocketSession::RemoteAddress()
{
std::lock_guard<std::mutex> lock(_remoteAddressMutex);
std::string ret(_remoteAddress);
return ret;
}
void WebSocketSession::SetRemoteAddress(std::string address)
{
std::lock_guard<std::mutex> lock(_remoteAddressMutex);
_remoteAddress = address;
}
uint64_t WebSocketSession::ConnectedAt()
{
return _connectedAt.load();

View File

@ -9,6 +9,9 @@ class WebSocketSession
public:
WebSocketSession();
std::string RemoteAddress();
void SetRemoteAddress(std::string address);
uint64_t ConnectedAt();
void SetConnectedAt(uint64_t at);
@ -40,6 +43,8 @@ class WebSocketSession
void SetEventSubscriptions(uint64_t subscriptions);
private:
std::mutex _remoteAddressMutex;
std::string _remoteAddress;
std::atomic<uint64_t> _connectedAt;
std::atomic<uint64_t> _incomingMessages;
std::atomic<uint64_t> _outgoingMessages;