aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>2019-05-16 14:20:09 +0800
committerwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>2019-05-16 14:20:09 +0800
commit85e6e550f1afb910b840967fae26db7c578ac06a (patch)
tree21baf910fa80d7750f2896cdf31631bcdfc3ccc8
parent44290c49e08fe52d6e3ed80720473577131090f4 (diff)
modify subscribe opportunity
Change-Id: I47ff97e4eab37e4b942c1721560f8b381ce14592
-rw-r--r--include/libhomescreen.hpp1
-rw-r--r--src/libhomescreen.cpp47
2 files changed, 21 insertions, 27 deletions
diff --git a/include/libhomescreen.hpp b/include/libhomescreen.hpp
index e51e01c..32a9121 100644
--- a/include/libhomescreen.hpp
+++ b/include/libhomescreen.hpp
@@ -65,6 +65,7 @@ public:
int onScreenReply(const char* reply_message);
void set_event_handler(enum EventType et, handler_func f);
+ void publishSubscription(void);
void registerCallback(
void (*event_cb)(const std::string& event, struct json_object* event_contents),
diff --git a/src/libhomescreen.cpp b/src/libhomescreen.cpp
index ad18ca4..71afa66 100644
--- a/src/libhomescreen.cpp
+++ b/src/libhomescreen.cpp
@@ -307,38 +307,31 @@ int LibHomeScreen::onScreenReply(const char* reply_message)
void LibHomeScreen::set_event_handler(enum EventType et, handler_func f)
{
if (et > Event_Min && et < Event_Max) {
- switch (et) {
- case Event_ShowWindow:
- this->subscribe(LibHomeScreen::event_list[0]);
- break;
- case Event_OnScreenMessage:
- this->subscribe(LibHomeScreen::event_list[1]);
- break;
- case Event_OnScreenReply:
- this->subscribe(LibHomeScreen::event_list[2]);
- break;
- case Event_HideWindow:
- this->subscribe(LibHomeScreen::event_list[3]);
- break;
- case Event_ReplyShowWindow:
- this->subscribe(LibHomeScreen::event_list[4]);
- break;
- case Event_ShowNotification:
- this->subscribe(LibHomeScreen::event_list[5]);
- break;
- case Event_ShowInformation:
- this->subscribe(LibHomeScreen::event_list[6]);
- break;
- case Event_AppListChanged:
- this->subscribe(LibHomeScreen::event_list[7]);
- break;
- }
-
this->handlers[et] = std::move(f);
}
}
/**
+ * This function subscribe HomeScreen event
+ *
+ * #### Parameters
+ * None
+ *
+ * #### Return
+ * - Nothing
+ *
+ * #### Note
+ * To call HomeScreen's subscribe APIs.
+ *
+ */
+void LibHomeScreen::publishSubscription(void)
+{
+ for(auto &it : handlers) {
+ this->subscribe(LibHomeScreen::event_list[it.first - 1]);
+ }
+}
+
+/**
* This function calls the API of HomeScreen via WebSocket
*
* #### Parameters