# oatpp-ssdp **Repository Path**: mirrors_oatpp/oatpp-ssdp ## Basic Information - **Project Name**: oatpp-ssdp - **Description**: Oat++ extension module to work with SSDP protocol. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-01-26 - **Last Updated**: 2025-12-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # oatpp-ssdp [![Build Status](https://dev.azure.com/lganzzzo/lganzzzo/_apis/build/status/oatpp.oatpp-ssdp?branchName=master)](https://dev.azure.com/lganzzzo/lganzzzo/_build/latest?definitionId=28&branchName=master) Oat++ extension module to work with SSDP (Simple Service Discovery Protocol) protocol. ๐Ÿ‘‰Find the complete example project using **oatpp-ssdp** module - [Example IoT Hue](https://github.com/oatpp/example-iot-hue-ssdp)๐Ÿ‘ˆ More about Oat++: - [Oat++ Website](https://oatpp.io/) - [Oat++ Github Repository](https://github.com/oatpp/oatpp) ## Build And Install *Note: you need to install the main [oatpp](https://github.com/oatpp/oatpp) module first.* - Clone this repository. - In the root of the repository run: ```bash mkdir build && cd build cmake .. make install ``` ## API ### Declare Necessary Components In the `AppComponent.hpp` file: ```cpp #include "oatpp-ssdp/SimpleSsdpUdpStreamProvider.hpp" #include "oatpp-ssdp/SsdpStreamHandler.hpp" ... /** * Create provider of SSDP-UDP packets stream. */ OATPP_CREATE_COMPONENT(std::shared_ptr, ssdpStreamProvider)("ssdp", [] { return oatpp::ssdp::SimpleSsdpUdpStreamProvider::createShared(); }()); /** * We can reuse the HttpRouter for SSDP since SSDP message is complient to HTTP1.1. */ OATPP_CREATE_COMPONENT(std::shared_ptr, ssdpRouter)("ssdp", [] { return oatpp::web::server::HttpRouter::createShared(); }()); /** * Create SsdpStreamHandler component which uses Router component to route requests. * It looks like a normal ConnectionHandler but is specialized on SsdpStreams and returns something conceptually very different */ OATPP_CREATE_COMPONENT(std::shared_ptr, ssdpStreamHandler)("ssdp", [] { OATPP_COMPONENT(std::shared_ptr, router, "ssdp"); // get Router component return oatpp::ssdp::SsdpStreamHandler::createShared(router); }()); ``` ### Run SSDP Server In the `App.cpp` file: ```cpp /* Get stream provider component */ OATPP_COMPONENT(std::shared_ptr, ssdpStreamProvider, "ssdp"); /* Get stream handler component */ OATPP_COMPONENT(std::shared_ptr, ssdpStreamHandler, "ssdp"); /* Create server which takes provided streams and passes them to stream handler */ oatpp::network::server::Server server(ssdpStreamProvider, ssdpStreamHandler); /* Priny info about server port */ OATPP_LOGD("Server", "Running SSDP on port %s...", ssdpStreamProvider->getProperty("port").getData()); /* Run server */ server.run(); ``` ### Handle SSDP Messages In the `Controller.hpp` file: ```cpp /** * Other devices that want to discover you send 'M-SEARCH *' SSDP packages. * You have to answer with a corresponding packet on this discovery. */ ENDPOINT("M-SEARCH", "*", star) { auto response = createResponse(Status::CODE_200, "" /* empty body */); // TODO - add correct response headers. return response; } ```