diff options
author | AppaRao Puli <apparao.puli@linux.intel.com> | 2020-05-15 18:39:54 +0300 |
---|---|---|
committer | AppaRao Puli <apparao.puli@linux.intel.com> | 2020-07-02 07:56:57 +0300 |
commit | 4bbf237f4217afd1a0fa8c474a921a9175732b13 (patch) | |
tree | d64066e1bb894362e3bafd9766fc9feecade27ad /redfish-core/lib/event_service.hpp | |
parent | fe44eb0b4b46fa3a96f445df05e962e15e5d337d (diff) | |
download | bmcweb-4bbf237f4217afd1a0fa8c474a921a9175732b13.tar.xz |
EventService: Support for Server Sent Events(SSE)
Add support for Server Sent Events(SSE)
Filters support is not part of this commit.
Tested:
- GET on URI /redfish/v1/EventService/Subscriptions/SSE/
from chrome browser, can see all BMC Events on browser.
- Redfish validator is successful.
Change-Id: Icd10cdad20c4529f64c97b67d46f2e4a7e0c329c
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
Diffstat (limited to 'redfish-core/lib/event_service.hpp')
-rw-r--r-- | redfish-core/lib/event_service.hpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp index ba1ea19053..adb62389cf 100644 --- a/redfish-core/lib/event_service.hpp +++ b/redfish-core/lib/event_service.hpp @@ -398,6 +398,66 @@ class EventDestinationCollection : public Node } }; +class EventServiceSSE : public Node +{ + public: + EventServiceSSE(CrowApp& app) : + Node(app, "/redfish/v1/EventService/Subscriptions/SSE/") + { + entityPrivileges = { + {boost::beast::http::verb::get, {{"ConfigureManager"}}}, + {boost::beast::http::verb::head, {{"ConfigureManager"}}}, + {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, + {boost::beast::http::verb::put, {{"ConfigureManager"}}}, + {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, + {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; + } + + private: + void doGet(crow::Response& res, const crow::Request& req, + const std::vector<std::string>& params) override + { + if (EventServiceManager::getInstance().getNumberOfSubscriptions() >= + maxNoOfSubscriptions) + { + messages::eventSubscriptionLimitExceeded(res); + res.end(); + return; + } + + std::shared_ptr<crow::Request::Adaptor> sseConn = + std::make_shared<crow::Request::Adaptor>(std::move(req.socket())); + std::shared_ptr<Subscription> subValue = + std::make_shared<Subscription>(sseConn); + + // GET on this URI means, Its SSE subscriptionType. + subValue->subscriptionType = "SSE"; + subValue->protocol = "Redfish"; + + char* filters = req.urlParams.get("$filter"); + if (filters == nullptr) + { + subValue->eventFormatType = "Event"; + subValue->retryPolicy = "TerminateAfterRetries"; + } + else + { + // TODO: Need to read this from query params. + subValue->eventFormatType = "Event"; + subValue->retryPolicy = "TerminateAfterRetries"; + } + + std::string id = + EventServiceManager::getInstance().addSubscription(subValue, false); + if (id.empty()) + { + messages::internalError(res); + res.end(); + return; + } + } +}; + class EventDestination : public Node { public: |