Commit 417b22d7 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Don't attempt MQTT functions when MQTT is disabled

This is to avoid the error reporting/logging that results.
parent 165a81a4
......@@ -569,19 +569,21 @@ bool sbbs_t::update_nodeterm(void)
}
strListFree(&ini);
char str[256];
char topic[128];
SAFEPRINTF(topic, "node%u/terminal", cfg.node_num);
snprintf(str, sizeof(str), "%lu\t%lu\t%s\t%s\t%lx\t%lx\t%lx"
,cols
,rows
,term_type()
,term_charset()
,term_supports()
,mouse_mode
,console
);
mqtt_pub_strval(&startup->mqtt, TOPIC_BBS, topic, str);
if(cfg.mqtt.enabled) {
char str[256];
char topic[128];
SAFEPRINTF(topic, "node%u/terminal", cfg.node_num);
snprintf(str, sizeof(str), "%lu\t%lu\t%s\t%s\t%lx\t%lx\t%lx"
,cols
,rows
,term_type()
,term_charset()
,term_supports()
,mouse_mode
,console
);
mqtt_pub_strval(&startup->mqtt, TOPIC_BBS, topic, str);
}
return result;
}
......
......@@ -2481,10 +2481,12 @@ void output_thread(void* arg)
sem_post(startup->node_spysem[sbbs->cfg.node_num-1]);
}
/* Spy on the user remotely */
int result = mqtt_pub_message(&startup->mqtt, TOPIC_BBS, spy_topic, buf+bufbot, i);
if(result != MQTT_SUCCESS)
lprintf(LOG_WARNING, "%s ERROR %d (%d) publishing node output (%u bytes): %s"
,node, result, errno, i, spy_topic);
if(sbbs->cfg.mqtt.enabled) {
int result = mqtt_pub_message(&startup->mqtt, TOPIC_BBS, spy_topic, buf+bufbot, i);
if(result != MQTT_SUCCESS)
lprintf(LOG_WARNING, "%s ERROR %d (%d) publishing node output (%u bytes): %s"
,node, result, errno, i, spy_topic);
}
if(spy_socket[sbbs->cfg.node_num-1]!=INVALID_SOCKET)
(void)sendsocket(spy_socket[sbbs->cfg.node_num-1],(char*)buf+bufbot,i);
#ifdef __unix__
......
......@@ -91,21 +91,22 @@ int sbbs_t::putnodedat(uint number, node_t* node)
}
pthread_mutex_unlock(&nodefile_mutex);
snprintf(str, sizeof(str), "%u\t%u\t%u\t%u\t%x\t%u\t%u\t%u"
,node->status
,node->action
,node->useron
,node->connection
,node->misc
,node->aux
,node->extaux
,node->errors
);
SAFEPRINTF(topic, "node%u/status", number + 1);
int result = mqtt_pub_strval(&startup->mqtt, TOPIC_BBS, topic, str);
if(result != MQTT_SUCCESS)
lprintf(LOG_WARNING, "ERROR %d (%d) publishing node status: %s", result, errno, topic);
if(cfg.mqtt.enabled) {
snprintf(str, sizeof(str), "%u\t%u\t%u\t%u\t%x\t%u\t%u\t%u"
,node->status
,node->action
,node->useron
,node->connection
,node->misc
,node->aux
,node->extaux
,node->errors
);
SAFEPRINTF(topic, "node%u/status", number + 1);
int result = mqtt_pub_strval(&startup->mqtt, TOPIC_BBS, topic, str);
if(result != MQTT_SUCCESS)
lprintf(LOG_WARNING, "ERROR %d (%d) publishing node status: %s", result, errno, topic);
}
if(wr!=sizeof(node_t)) {
errno=wrerr;
errormsg(WHERE,ERR_WRITE,"nodefile",number+1);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment