mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
WebSocketServer: Add GetWebSocketSessions() logic
This commit is contained in:
parent
3d43bd525b
commit
5348c80aa8
@ -1,6 +1,7 @@
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <QtConcurrent>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "WebSocketServer.h"
|
||||
#include "obs-websocket.h"
|
||||
@ -126,9 +127,21 @@ void WebSocketServer::InvalidateSession(websocketpp::connection_hdl hdl)
|
||||
_server.close(hdl, WebSocketCloseCode::SessionInvalidated, "Your session has been invalidated.");
|
||||
}
|
||||
|
||||
std::vector<WebSocketServer::WebSocketState> WebSocketServer::GetWebSocketSessions()
|
||||
std::vector<WebSocketServer::WebSocketSessionState> WebSocketServer::GetWebSocketSessions()
|
||||
{
|
||||
std::vector<WebSocketServer::WebSocketState> webSocketSessions;
|
||||
std::vector<WebSocketServer::WebSocketSessionState> webSocketSessions;
|
||||
|
||||
std::unique_lock<std::mutex> lock(_sessionMutex);
|
||||
for (auto & [hdl, session] : _sessions) {
|
||||
uint64_t connectedAt = session.ConnectedAt();
|
||||
uint64_t incomingMessages = session.IncomingMessages();
|
||||
uint64_t outgoingMessages = session.OutgoingMessages();
|
||||
std::string remoteAddress = session.RemoteAddress();
|
||||
|
||||
webSocketSessions.emplace_back(WebSocketSessionState{hdl, remoteAddress, connectedAt, incomingMessages, outgoingMessages});
|
||||
}
|
||||
lock.unlock();
|
||||
|
||||
return webSocketSessions;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ uint64_t WebSocketSession::ConnectedAt()
|
||||
return _connectedAt.load();
|
||||
}
|
||||
|
||||
void WebSocketSession::SetConnectedAt(uint64_t at);
|
||||
void WebSocketSession::SetConnectedAt(uint64_t at)
|
||||
{
|
||||
_connectedAt.store(at);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user