wangrong
2025-03-19 291afb9c81aae1d15d9e3edcea618d0a2e1fc5a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
 
#include "vp_msg_broker_node.h"
#include "../../objects/ba/vp_ba_result.h"
#include "cereal_archive/vp_objects_cereal_archive.h"
 
// light weight socket support
#include "../../third_party/kissnet/kissnet.hpp"
 
namespace vp_nodes {
    // message broker node, broke math expression checking results (ONLY for vp_frame_text_target) to socket via udp.
    // math expression checking results could be used for archive.
    class vp_expr_socket_broker_node: public vp_msg_broker_node
    {
    private:
        // save dir for screenshot images, which would be used for displaying in web client
        std::string screenshot_dir = "screenshot_images";
        // host the data sent to via udp
        std::string des_ip = "";
        // port the data sent to via udp
        int des_port = 0;
 
        // udp socket writer
        kissnet::udp_socket udp_writer;
    protected:
        // to custom format
        virtual void format_msg(const std::shared_ptr<vp_objects::vp_frame_meta>& meta, std::string& msg) override;
        // to socket via udp
        virtual void broke_msg(const std::string& msg) override;
    public:
        vp_expr_socket_broker_node(std::string node_name, 
                                std::string des_ip = "",
                                int des_port = 0,
                                std::string screenshot_dir = "screenshot_images",
                                vp_broke_for broke_for = vp_broke_for::TEXT, 
                                int broking_cache_warn_threshold = 50, 
                                int broking_cache_ignore_threshold = 200);
        ~vp_expr_socket_broker_node();
    };
}