From cbb18a85dc4df6ca1317f543db5a9da7b84cf9e1 Mon Sep 17 00:00:00 2001 From: wang_zhiqiang Date: Wed, 21 Nov 2018 16:02:53 +0800 Subject: Improvement:a client instance only call afb_req_subscribe once when call subscribe every time, hs_client instance will call afb_req_subscribe once, this is needless, every hs_client always only has one event, so only need to call afb_req_subscribe once. Change-Id: I91417b749201fc378287e03f08dfd4dfd5df9dc7 Signed-off-by: wang_zhiqiang --- src/hs-client.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/hs-client.cpp') diff --git a/src/hs-client.cpp b/src/hs-client.cpp index 26e43bb..536ff6e 100644 --- a/src/hs-client.cpp +++ b/src/hs-client.cpp @@ -142,7 +142,12 @@ int HS_Client::subscribe(afb_req_t request, const char* event) auto ip = event_list.find(std::string(event)); if(ip == event_list.end()) { event_list[std::string(event)] = 0; + } + if(!subscription) { ret = afb_req_subscribe(request, my_event); + if(ret == 0) { + subscription = true; + } } return ret; } -- cgit 1.2.3-korg