| 14 | |
| 15 | template <typename ...Args> |
| 16 | class MySubMessageNode : public CGraph::GTemplateNode<Args ...> { |
| 17 | public: |
| 18 | explicit MySubMessageNode(int connId) { |
| 19 | conn_id_ = connId; |
| 20 | } |
| 21 | |
| 22 | CStatus init() override { |
| 23 | CGraph::CGRAPH_ECHO("==> [%s] [init] get conn id = [%d]", |
| 24 | this->getName().c_str(), conn_id_); |
| 25 | return CStatus(); |
| 26 | } |
| 27 | |
| 28 | CStatus run() override { |
| 29 | std::shared_ptr<MyMessageParam> mp = nullptr; // 通过智能指针类型,接收一个消息。相比value接收(Recv or Sub),性能会好一些 |
| 30 | CStatus status = CGRAPH_SUB_MPARAM(MyMessageParam, conn_id_, mp) |
| 31 | if (!status.isOK()) { |
| 32 | CGraph::CGRAPH_ECHO("[%s] recv message error", this->getName().c_str()); |
| 33 | return status; |
| 34 | } |
| 35 | |
| 36 | CGraph::CGRAPH_ECHO("[%s] conn id = [%d], num = [%d], info = [%s]", |
| 37 | this->getName().c_str(), conn_id_, mp->num, mp->info.c_str()); |
| 38 | return status; |
| 39 | } |
| 40 | |
| 41 | private: |
| 42 | CIndex conn_id_; |
| 43 | }; |
| 44 | |
| 45 | #endif //CGRAPH_MYSUBMESSAGENODE_H |
nothing calls this directly
no outgoing calls
no test coverage detected