/
Stormbery
/
CEX
Обзор
Документация
Войти
/
Stormbery
/
CEX
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
include/websocketstream.h
82 строки
3 KB
stormbery
deleted plots objects
20 сен 2024, 21:17
20 сен 2024, 21:17
4e0e245
Код
Авторство
О чём код?
/** * \file Файл описания класса CoreWorker * * Файл содержит определение класса ядра */ #ifndef PUBLICSTREAM_H #define PUBLICSTREAM_H #include <boost/enable_shared_from_this.hpp> #include <boost/make_shared.hpp> #include <iostream> //#include "coin.h" //#include<boost/iterator/advance.hpp> //#include <iterator> //#include"boost/property_tree/json_parser.hpp" #include <boost/asio/use_awaitable.hpp> #include <boost/asio/awaitable.hpp> #include <boost/beast/core.hpp> #include <boost/beast/http.hpp> #include <boost/beast/ssl.hpp> #include <boost/beast/version.hpp> #include <boost/asio/strand.hpp> #include <boost/asio/as_tuple.hpp> #include <boost/asio/co_spawn.hpp> #include <boost/asio/detached.hpp> #include <boost/thread.hpp> #include <boost/atomic.hpp> #include <boost/property_tree/ptree.hpp> #include <boost/json.hpp> #include <boost/beast/websocket.hpp> #include <boost/beast/websocket/ssl.hpp> #include <iostream> #include <boost/asio/experimental/as_tuple.hpp> #include <boost/asio/thread_pool.hpp> #include <boost/asio/executor_work_guard.hpp> #include <boost/asio/buffers_iterator.hpp> #include <boost/lexical_cast.hpp> #include <boost/multiprecision/cpp_dec_float.hpp> namespace beast = boost::beast; // from <boost/beast.hpp> namespace http = beast::http; // from <boost/beast/http.hpp> namespace net = boost::asio; // from <boost/asio.hpp> namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp> namespace websocket = beast::websocket; // from <boost/beast/websocket.hpp> namespace json = boost::json; // from <boost/json.hpp> using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp> using net::use_awaitable; using net::experimental::as_tuple; using namespace boost; class Coin; class WebSocketStream: public enable_shared_from_this<WebSocketStream> { WebSocketStream &operator = (const WebSocketStream &) = delete; WebSocketStream (const WebSocketStream &source) = delete; net::io_context m_ioc;///<контекст IOC net::any_io_executor m_iocStrand; ssl::context m_ctx{ssl::context::tlsv12_client}; boost::atomic<bool> m_RequestLoopEnable;///< запуск/останов цикла запросов net::executor_work_guard<net::any_io_executor> m_workguard; std::string m_pair;///<запрошенная пара boost::shared_ptr<boost::thread> m_threadIOC_[5];///< указатели на потоки выполнения IOC boost::shared_ptr<Coin> m_ptr_coin;///< указатель на основной класс //bool m_WebSocketOpen; uint16_t m_WebSocketOpen; public: WebSocketStream(); ~WebSocketStream(); void AddPublicStream(std::string host, std::string stream, std::string subscribe); void StopWebSocket(); // void StopIOC(); void SetPair(std::string pair); void SetPtr(boost::shared_ptr<Coin> m_ptr); }; #endif // PUBLICSTREAM_H