| | |
| | | return true; |
| | | } |
| | | |
| | | // 订阅 |
| | | int BHSubscribeTopics(const void *topics, const int topics_len, void **reply, int *reply_len, const int timeout_ms) |
| | | { |
| | | static int sub(const string& url, const void *topics, const int topics_len, void **reply, int *reply_len, const int timeout_ms){ |
| | | if (!topics || topics_len <= 0) return false; |
| | | |
| | | bhome_msg::MsgTopicList mtl; |
| | |
| | | // printf("BHSubscribeTopics %s\n", t.c_str()); |
| | | subscribe_topic(t); |
| | | } |
| | | return true; |
| | | auto ret = simple_request(get_url(URLSubLocal), topics, topics_len, reply, reply_len, timeout_ms); |
| | | |
| | | auto ret = simple_request(url, topics, topics_len, reply, reply_len, timeout_ms); |
| | | if (!ret){ |
| | | printf("BHSubscribeTopics simple_request failed\n"); |
| | | } |
| | | return ret; |
| | | } |
| | | // 订阅 |
| | | int BHSubscribeTopics(const void *topics, const int topics_len, void **reply, int *reply_len, const int timeout_ms) |
| | | { |
| | | return sub(get_url(URLSubLocal), topics, topics_len, reply, reply_len, timeout_ms); |
| | | } |
| | | // 订阅网络,不实现 |
| | | int BHSubscribeNetTopics(const void *topics, const int topics_len, void **reply, int *reply_len, const int timeout_ms) |
| | | { |
| | | return BHSubscribeTopics(topics, topics_len, reply, reply_len, timeout_ms); |
| | | return sub(get_url(URLSubNet), topics, topics_len, reply, reply_len, timeout_ms); |
| | | } |
| | | |
| | | // 读取订阅消息,proc_id暂时没用,返回fake msg |
| | |
| | | return simple_request(url, query, query_len, reply, reply_len, timeout_ms); |
| | | } |
| | | |
| | | int bus_subscribe_topics(void* handle, const void *topics, |
| | | static int sub(const string& url,void* handle, const void *topics, |
| | | const int topics_len, |
| | | void **reply, |
| | | int *reply_len, |
| | | const int timeout_ms) |
| | | { |
| | | const int timeout_ms){ |
| | | |
| | | TAG; |
| | | bus* b = get(handle); |
| | | if (!b){ |
| | |
| | | subscribe_topic(mtl.topic_list(i), &get<2>(*b)); |
| | | } |
| | | |
| | | return true; |
| | | |
| | | /////////////////////////////////////////////////// |
| | | auto ret = simple_request(get_url(URLSubLocal), topics, topics_len, reply, reply_len, timeout_ms); |
| | | auto ret = simple_request(url, topics, topics_len, reply, reply_len, timeout_ms); |
| | | if (!ret){ |
| | | printf("bus_subscribe_topics simple_request failed\n"); |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | int bus_subscribe_topics(void* handle, const void *topics, |
| | | const int topics_len, |
| | | void **reply, |
| | | int *reply_len, |
| | | const int timeout_ms) |
| | | { |
| | | return sub(get_url(URLSubLocal), handle, topics, topics_len, reply, reply_len, timeout_ms); |
| | | } |
| | | int bus_subscribe_topics_net(void* handle, const void *topics, |
| | | const int topics_len, |
| | | void **reply, |
| | | int *reply_len, |
| | | const int timeout_ms) |
| | | { |
| | | return bus_subscribe_topics(handle, topics, topics_len, reply, reply_len, timeout_ms); |
| | | return sub(get_url(URLSubNet), handle, topics, topics_len, reply, reply_len, timeout_ms); |
| | | } |
| | | |
| | | int bus_heartbeat_easy(void* handle, const int timeout_ms){ return 1; } |