From 153375e3b152768cbffce715d049499945834c29 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期二, 13 四月 2021 15:11:14 +0800
Subject: [PATCH] add api code, use proto msg as data.

---
 src/defs.cpp |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/defs.cpp b/src/defs.cpp
index cab4fc7..bab2e53 100644
--- a/src/defs.cpp
+++ b/src/defs.cpp
@@ -23,8 +23,31 @@
 const MQId kBHTopicReqRepCenter = boost::uuids::string_generator()("12345670-89ab-cdef-8349-1234567890ff");
 const MQId kBHUniCenter = boost::uuids::string_generator()("87654321-89ab-cdef-8349-1234567890ff");
 
+struct LastError {
+	int ec_ = 0;
+	std::string msg_;
+};
+
+LastError &LastErrorStore()
+{
+	thread_local LastError le;
+	return le;
+}
+
 } // namespace
 
 const MQId &BHTopicBusAddress() { return kBHTopicBus; }
 const MQId &BHTopicCenterAddress() { return kBHTopicReqRepCenter; }
 const MQId &BHUniCenterAddress() { return kBHUniCenter; }
+
+void SetLastError(const int ec, const std::string &msg)
+{
+	LastErrorStore().ec_ = ec;
+	LastErrorStore().msg_ = msg;
+}
+
+void GetLastError(int &ec, std::string &msg)
+{
+	ec = LastErrorStore().ec_;
+	msg = LastErrorStore().msg_;
+}
\ No newline at end of file

--
Gitblit v1.8.0