requesthandler: Don't require session for Request Handler

Required to call requests in situations where a session is not
relevant.
This commit is contained in:
tt2468 2022-05-10 19:51:51 -07:00
parent 1cd12c1023
commit 3303acfcca
2 changed files with 8 additions and 3 deletions

View File

@ -37,7 +37,7 @@ typedef RequestResult(RequestHandler::*RequestMethodHandler)(const Request&);
class RequestHandler {
public:
RequestHandler(SessionPtr session);
RequestHandler(SessionPtr session = nullptr);
RequestResult ProcessRequest(const Request& request);
std::vector<std::string> GetRequestList();

View File

@ -92,8 +92,13 @@ RequestResult RequestHandler::GetStats(const Request&)
{
json responseData = Utils::Obs::ObjectHelper::GetStats();
responseData["webSocketSessionIncomingMessages"] = _session->IncomingMessages();
responseData["webSocketSessionOutgoingMessages"] = _session->OutgoingMessages();
if (_session) {
responseData["webSocketSessionIncomingMessages"] = _session->IncomingMessages();
responseData["webSocketSessionOutgoingMessages"] = _session->OutgoingMessages();
} else {
responseData["webSocketSessionIncomingMessages"] = nullptr;
responseData["webSocketSessionOutgoingMessages"] = nullptr;
}
return RequestResult::Success(responseData);
}