From 5b6ced44157b6e7fab519ae48f5cffcdc2b3cd7c Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期日, 25 四月 2021 19:28:57 +0800
Subject: [PATCH] use node mqid ssn id to index online nodes.

---
 src/topic_node.cpp |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/topic_node.cpp b/src/topic_node.cpp
index 9398318..13bb8ee 100644
--- a/src/topic_node.cpp
+++ b/src/topic_node.cpp
@@ -89,7 +89,7 @@
 	AddId(SockSub().id());
 	AddId(SockPub().id());
 
-	auto head(InitMsgHead(GetType(body), body.proc().proc_id()));
+	auto head(InitMsgHead(GetType(body), body.proc().proc_id(), ssn()));
 	AddRoute(head, sock.id());
 
 	auto CheckResult = [this](MsgI &msg, BHMsgHead &head, MsgCommonReply &rbody) {
@@ -129,7 +129,7 @@
 	MsgUnregister body;
 	body.mutable_proc()->Swap(&proc);
 
-	auto head(InitMsgHead(GetType(body), body.proc().proc_id()));
+	auto head(InitMsgHead(GetType(body), body.proc().proc_id(), ssn()));
 	AddRoute(head, sock.id());
 
 	auto CheckResult = [this](MsgI &msg, BHMsgHead &head, MsgCommonReply &rbody) {
@@ -165,7 +165,7 @@
 	MsgHeartbeat body;
 	body.mutable_proc()->Swap(&proc);
 
-	auto head(InitMsgHead(GetType(body), body.proc().proc_id()));
+	auto head(InitMsgHead(GetType(body), body.proc().proc_id(), ssn()));
 	AddRoute(head, sock.id());
 
 	if (timeout_ms == 0) {
@@ -195,7 +195,7 @@
 	}
 	auto &sock = SockNode();
 
-	BHMsgHead head(InitMsgHead(GetType(query), proc_id()));
+	BHMsgHead head(InitMsgHead(GetType(query), proc_id(), ssn()));
 	AddRoute(head, sock.id());
 
 	MsgI reply;
@@ -217,7 +217,7 @@
 	MsgRegisterRPC body;
 	body.mutable_topics()->Swap(&topics);
 
-	auto head(InitMsgHead(GetType(body), proc_id()));
+	auto head(InitMsgHead(GetType(body), proc_id(), ssn()));
 	AddRoute(head, sock.id());
 
 	if (timeout_ms == 0) {
@@ -242,7 +242,7 @@
 
 		MsgRequestTopicReply reply_body;
 		if (rcb(head.proc_id(), req, reply_body)) {
-			BHMsgHead reply_head(InitMsgHead(GetType(reply_body), proc_id(), head.msg_id()));
+			BHMsgHead reply_head(InitMsgHead(GetType(reply_body), proc_id(), ssn(), head.msg_id()));
 
 			for (int i = 0; i < head.route_size() - 1; ++i) {
 				reply_head.add_route()->Swap(head.mutable_route(i));
@@ -311,7 +311,7 @@
 	if (!p || p->route.empty()) {
 		return false;
 	}
-	BHMsgHead head(InitMsgHead(GetType(body), proc_id(), p->msg_id));
+	BHMsgHead head(InitMsgHead(GetType(body), proc_id(), ssn(), p->msg_id));
 	for (unsigned i = 0; i < p->route.size() - 1; ++i) {
 		head.add_route()->Swap(&p->route[i]);
 	}
@@ -348,7 +348,7 @@
 
 	auto SendTo = [this, msg_id](const BHAddress &addr, const MsgRequestTopic &req, const RequestResultCB &cb) {
 		auto &sock = SockClient();
-		BHMsgHead head(InitMsgHead(GetType(req), proc_id(), msg_id));
+		BHMsgHead head(InitMsgHead(GetType(req), proc_id(), ssn(), msg_id));
 		AddRoute(head, sock.id());
 		head.set_topic(req.topic());
 
@@ -388,7 +388,7 @@
 
 		BHAddress addr;
 		if (ClientQueryRPCTopic(request.topic(), addr, timeout_ms)) {
-			BHMsgHead head(InitMsgHead(GetType(request), proc_id()));
+			BHMsgHead head(InitMsgHead(GetType(request), proc_id(), ssn()));
 			AddRoute(head, sock.id());
 			head.set_topic(request.topic());
 
@@ -460,7 +460,7 @@
 
 	try {
 		auto &sock = SockPub();
-		BHMsgHead head(InitMsgHead(GetType(pub), proc_id()));
+		BHMsgHead head(InitMsgHead(GetType(pub), proc_id(), ssn()));
 		AddRoute(head, sock.id());
 
 		if (timeout_ms == 0) {
@@ -494,7 +494,7 @@
 		MsgSubscribe sub;
 		sub.mutable_topics()->Swap(&topics);
 
-		BHMsgHead head(InitMsgHead(GetType(sub), proc_id()));
+		BHMsgHead head(InitMsgHead(GetType(sub), proc_id(), ssn()));
 		AddRoute(head, sock.id());
 		if (timeout_ms == 0) {
 			return sock.Send(BHTopicBusAddress(), head, sub);

--
Gitblit v1.8.0