mirror of
https://github.com/emqx/neuron.git
synced 2026-10-22 09:23:52 +08:00
Add call config function of plugin when receive pong message
This commit is contained in:
@@ -397,6 +397,7 @@ static int mqtt_plugin_init(neu_plugin_t *plugin)
|
||||
}
|
||||
|
||||
plugin_subscribe(plugin, "neuronlite/request", 0, plugin_response_handle);
|
||||
log_info("Initialize plugin: %s", neu_plugin_module.module_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -404,6 +405,7 @@ static int mqtt_plugin_uninit(neu_plugin_t *plugin)
|
||||
{
|
||||
paho_client_close(plugin->paho);
|
||||
|
||||
log_info("Uninitialize plugin: %s", neu_plugin_module.module_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -411,6 +413,8 @@ static int mqtt_plugin_config(neu_plugin_t *plugin, neu_config_t *configs)
|
||||
{
|
||||
UNUSED(plugin);
|
||||
UNUSED(configs);
|
||||
|
||||
log_info("config plugin: %s", neu_plugin_module.module_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+21
-1
@@ -133,9 +133,29 @@ static void adapter_loop(void *arg)
|
||||
pay_msg = nng_msg_body(msg);
|
||||
switch (msg_get_type(pay_msg)) {
|
||||
case MSG_CMD_RESP_PONG: {
|
||||
bool need_config;
|
||||
char *buf_ptr;
|
||||
buf_ptr = msg_get_buf_ptr(pay_msg);
|
||||
|
||||
need_config = false;
|
||||
buf_ptr = msg_get_buf_ptr(pay_msg);
|
||||
log_info("Adapter(%s) received pong: %s", adapter->name, buf_ptr);
|
||||
nng_mtx_lock(adapter->mtx);
|
||||
if (adapter->state == ADAPTER_STATE_IDLE) {
|
||||
need_config = true;
|
||||
adapter->state = ADAPTER_STATE_RUNNING;
|
||||
}
|
||||
nng_mtx_unlock(adapter->mtx);
|
||||
|
||||
if (need_config) {
|
||||
const neu_plugin_intf_funs_t *intf_funs;
|
||||
neu_config_t config;
|
||||
|
||||
config.type = NEU_CONFIG_UNKNOW;
|
||||
config.buf_len = 0;
|
||||
config.buf = NULL;
|
||||
intf_funs = adapter->plugin_module->intf_funs;
|
||||
intf_funs->config(adapter->plugin, &config);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user