Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ws_impl
- : public std::enable_shared_from_this<ws_impl>
- {
- ALLOW_MAKE_SHARED(ws_impl)
- public:
- static std::shared_ptr<ws_impl> create(std::shared_ptr<websocket_client> client, uint32_t archive_idx, qt::qthread_executor& exec, std::shared_ptr<source_model> model, std::shared_ptr<archive_proxy_concurrent> archive)
- {
- auto object = std::make_shared<ws_impl>(client, archive_idx, exec, model, archive);
- object->run();
- return object;
- }
- void shutdown()
- {
- client_->unsubscribe_from_websocket(sources_token_);
- }
- ~ws_impl()
- {
- shutdown();
- }
- private:
- ws_impl(std::shared_ptr<websocket_client> client, uint32_t archive_idx, qt::qthread_executor& exec, std::shared_ptr<source_model> model, std::shared_ptr<archive_proxy_concurrent> archive)
- : client_(client)
- , archive_idx_(archive_idx_)
- , exec_(exec)
- , model_(*model)
- , archive_(archive)
- {
- }
- void run()
- {
- std::string resource = "/sources/";
- sources_token_ = fmt::format("{:x}_{}", ao::bit_cast<uint64_t>(this), resource);
- client_->subscribe_to_websocket(resource, sources_token_, 0,
- boost::asio::bind_post(exec_,
- [this /*, self = shared_from_this() */ , resource](const nlohmann::json& js, boost::system::error_code e)
- {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement