#pragma once #include "ros_bridge/include/ComPrivateInclude.h" #include "ros_bridge/include/RosBridgeClient.h" #include "ros_bridge/include/TypeFactory.h" #include "ros_bridge/include/CasePacker.h" namespace ROSBridge { namespace ComPrivate { class TopicSubscriber { typedef std::vector ClientList; public: typedef std::function CallbackType; typedef std::map CallbackMap; TopicSubscriber() = delete; TopicSubscriber(CasePacker *casePacker, RosbridgeWsClient *rbc); ~TopicSubscriber(); //! @brief Starts the subscriber. void start(); //! @brief Resets the subscriber. void reset(); //! @return Returns false if a subscription to this topic allready exists. //! //! @note Only one callback can be registered. bool subscribe(const char* topic, const CallbackType &callback); private: CasePacker *_casePacker; RosbridgeWsClient *_rbc; CallbackMap _callbackMap; ClientList _clientList; bool _running; }; void subscriberCallback(const HashType &hash, const TopicSubscriber::CallbackMap &map, std::shared_ptr /*connection*/, std::shared_ptr in_message); void test(std::shared_ptr /*connection*/, std::shared_ptr in_message); } // namespace ComPrivate } // namespace ROSBridge