OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
coap_client_protocol.hpp
1#pragma once
2#include <ossia/detail/audio_spin_mutex.hpp>
3#include <ossia/detail/timer.hpp>
4#include <ossia/detail/variant.hpp>
5#include <ossia/network/base/protocol.hpp>
6#include <ossia/network/context.hpp>
7#include <ossia/network/sockets/configuration.hpp>
8
9#include <boost/asio/cancellation_signal.hpp>
10#include <boost/asio/strand.hpp>
11#include <boost/unordered/concurrent_flat_map.hpp>
12
13namespace ossia::net
14{
15struct coap_session;
16using strand_type
17 = decltype(boost::asio::make_strand(std::declval<boost::asio::io_context&>()));
18struct coap_client_configuration
19{
20 ossia::variant<udp_configuration, tcp_client_configuration, ws_client_configuration>
21 transport;
22};
23struct coap_client;
24class OSSIA_EXPORT coap_client_protocol
26 , public Nano::Observer
27{
28public:
29 explicit coap_client_protocol(
30 ossia::net::network_context_ptr, const coap_client_configuration& conf);
31 ~coap_client_protocol();
32
33 bool pull(parameter_base&) override;
34 bool push(const parameter_base&, const value& v) override;
35 bool push_raw(const full_parameter_data&) override;
36 bool observe(parameter_base&, bool) override;
37 bool update(node_base& node_base) override;
38 void set_device(device_base& dev) override;
39 void stop() override;
40
41private:
42 void request_namespace(ossia::net::node_base& root, std::string_view req);
43 void parse_namespace(ossia::net::node_base& dev, std::string_view data);
44
45 ossia::net::network_context_ptr m_context;
46 ossia::net::device_base* m_device{};
47 coap_client_configuration m_conf{};
48
49 std::unique_ptr<coap_client> m_client;
50 boost::unordered::concurrent_flat_map<std::string, std::shared_ptr<coap_session>>
51 m_topics;
52
53 strand_type m_strand;
54 std::string m_host;
55
56 ossia::timer m_timer;
57};
58}
Root of a device tree.
Definition ossia/network/base/device.hpp:58
The node_base class.
Definition node.hpp:48
The protocol_base class.
Definition protocol.hpp:40