| | |
| | | if (bus_client_request(handle, reqmsg, pptr_repmsg)) { |
| | | printf("======>> bus_client_reqest [%s] get [%s]\n", topic, (*pptr_repmsg)->data); |
| | | } else { |
| | | free(reqData); |
| | | return false; |
| | | } |
| | | |
| | | len = strlen((*pptr_repmsg)->data) + 1; |
| | | |
| | | free(reqData); |
| | | free(reqData); |
| | | return true; |
| | | } |
| | | |
| | | |
| | |
| | | yyjson_type type = YYJSON_TYPE_OBJ; |
| | | crepmsg *repmsg = NULL; |
| | | size_t len = 0; |
| | | bool bRet = false; |
| | | |
| | | bus_dbapi_get_topic_data(handle, topic, &repmsg, len); |
| | | |
| | |
| | | } |
| | | |
| | | std::string jsonString = msgdata; |
| | | if (json_to_proto(jsonString, message)) |
| | | bRet = json_to_proto(jsonString, message); |
| | | if (bRet) |
| | | { |
| | | printf("======>> json_to_proto done\n"); |
| | | } |
| | | else |
| | | { |
| | | printf("======>> json_to_proto fail\n"); |
| | | return false; |
| | | } |
| | | |
| | | free(msgdata); |
| | | free_reply_msg(repmsg); |
| | | |
| | | return true; |
| | | return bRet; |
| | | } |
| | | |
| | | /***************************************************************************** |
| | | 函 数 名 : bus_dbapi_get_str |
| | | 功能描述 : 获取订阅主题消息字符串,返回的内存调用者需要手工调用free函数释放 |
| | | 输入参数 : void *handle |
| | | const char* topic |
| | | char **pptr_str |
| | | 输出参数 : 无 |
| | | 返 回 值 : |
| | | 调用函数 : |
| | | 被调函数 : |
| | | |
| | | 修改历史 : |
| | | 1.日 期 : 2023年1月13日 |
| | | 作 者 : cheliequan |
| | | 修改内容 : 新生成函数 |
| | | |
| | | *****************************************************************************/ |
| | | bool bus_dbapi_get_str(void *handle, const char* topic, char **pptr_str) { |
| | | yyjson_type type = YYJSON_TYPE_OBJ; |
| | | crepmsg *repmsg = NULL; |
| | | size_t len = 0; |
| | | int iRet = 0; |
| | | bool bRet = false; |
| | | |
| | | bus_dbapi_get_topic_data(handle, topic, &repmsg, len); |
| | | |
| | | int msglen = strlen(repmsg->data); |
| | | char* msgdata = (char *)malloc(msglen); |
| | | memset(msgdata, 0 , msglen); |
| | | |
| | | iRet = bus_dbapi_get_json_data((const char *)repmsg->data, &msgdata, &type); |
| | | if(0 == iRet) |
| | | { |
| | | printf("======>> protomsg: %s\n", msgdata); |
| | | bRet = true; |
| | | } |
| | | |
| | | *pptr_str = msgdata; |
| | | |
| | | free(msgdata); |
| | | free_reply_msg(repmsg); |
| | | |
| | | return bRet; |
| | | } |