Commit 3e279d76 authored by Rohit Verma's avatar Rohit Verma 💬
Browse files

Add Prefix for topic

parent 4cbe8149
Pipeline #2633 passed with stage
in 1 minute and 1 second
......@@ -1062,7 +1062,6 @@ static void _register_listener (event_listener_t *listener)
}
static void *_test_thread(void *arg){
//client_t *client = (client_t *)arg;
stats_event_t *event;
event_listener_t listener;
......@@ -1088,9 +1087,28 @@ static void *_test_thread(void *arg){
if (event != NULL){
ICECAST_LOG_DEBUG("Testing Thread -> |%s| [%s] (%s)",event->mount, event->name, event->value);
#ifdef HAVE_LIBMOSQUITTO
if(event->value != NULL && event->name != NULL){
mosquitto_publish(mosq, NULL, event->name, strlen(event->value), event->value, 1, false);
const char *global_topic = "Icecast/legacy/global/";
const char *non_global_topic = "Icecast/legacy/";
if (event->value != NULL && event->name != NULL){
/*global events*/
char *event_name = event->name;
char *topic = (char *) malloc(1 + sizeof(char*) + (strlen(event_name) + strlen(global_topic)));
strcpy(topic, global_topic);
strcat(topic, event_name);
ICECAST_LOG_DEBUG("Rohit Checking %s", topic);
mosquitto_publish(mosq, NULL, topic, strlen(event->value), event->value, 1, false);
}
if (event->value != NULL && event->name == "source_id"){
/*non-global events*/
char *topic = (char *) malloc(1 + sizeof(char *) + (strlen(event->name) + strlen(non_global_topic)));
strcpy(topic, non_global_topic);
strcat(topic, event->name);
ICECAST_LOG_DEBUG("Rohit Checking %s ", topic);
mosquitto_publish(mosq, NULL, topic, strlen(event->value), event->value, 1, false);
}
#endif
free(event);
......@@ -1101,11 +1119,9 @@ static void *_test_thread(void *arg){
thread_mutex_lock(&_stats_mutex);
_unregister_listener (&listener);
//_test_threads--;
thread_mutex_unlock(&_stats_mutex);
thread_mutex_destroy (&listener.mutex);
//client_destroy (client);
ICECAST_LOG_DEBUG("Test Client Finised");
return NULL;
......
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