mod_netconf: add eventtime to notifications for ws
add missing eventtime in websocket messages with notifications
diff --git a/src/mod_netconf.c b/src/mod_netconf.c
index f4c7bf0..42fb5bf 100644
--- a/src/mod_netconf.c
+++ b/src/mod_netconf.c
@@ -209,7 +209,7 @@
void prepare_status_message(server_rec* server, struct session_with_mutex *s, struct nc_session *session)
{
json_object *json_obj;
- json_object *old_sid = NULL;
+ //json_object *old_sid = NULL;
const char *cpbltstr;
struct nc_cpblts* cpblts = NULL;
diff --git a/src/notification-server.c b/src/notification-server.c
index e4bdce1..b7d334e 100644
--- a/src/notification-server.c
+++ b/src/notification-server.c
@@ -512,7 +512,7 @@
}
return;
}
- ntf->eventtime = time(NULL);
+ ntf->eventtime = eventtime;
ntf->content = strdup(content);
if (http_server != NULL) {
@@ -708,11 +708,15 @@
while ((notif = (notification_t *) apr_array_pop(ls->notifications)) != NULL) {
char t[128];
- t[0] = 0;
+ memset(&t, 0, 128);
strftime(t, sizeof(t), "%c", localtime(¬if->eventtime));
n = 0;
- n = sprintf((char *)p, "%s\n", notif->content);
- m = libwebsocket_write(wsi, p, n, LWS_WRITE_TEXT);
+ json_object *notif_json = json_object_new_object();
+ json_object_object_add(notif_json, "eventtime", json_object_new_string(t));
+ json_object_object_add(notif_json, "content", json_object_new_string(notif->content));
+
+ char *msgtext = json_object_to_json_string(notif_json);
+ m = libwebsocket_write(wsi, (unsigned char *) msgtext, strlen(msgtext), LWS_WRITE_TEXT);
}
if (http_server != NULL) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, http_server, "notification: POP notifications done");