From: Michal Sojka Date: Thu, 16 Aug 2018 21:48:47 +0000 (+0200) Subject: Do not generate "empty" messages X-Git-Url: https://rtime.felk.cvut.cz/gitweb/coffee/mt-apps.git/commitdiff_plain/450ad3b3f18404933a8280ea20a734187e86d53b Do not generate "empty" messages They were probably not used for anything useful. They cluttered logs and made debugging harder. --- diff --git a/mt_server.c b/mt_server.c index c683c75..ee80d87 100644 --- a/mt_server.c +++ b/mt_server.c @@ -193,34 +193,15 @@ static int callback_merica_terminal(struct lws *wsi, lws_callback_on_writable_all_protocol(context, &protocols[PROTOCOL_MERICA_TERMINAL]); } - } else { - line = copy_line(JSON_EMPTY); - if (line) { - n = strlen(line); - m = lws_write(wsi, (unsigned char *)line, n, LWS_WRITE_TEXT); - free_line(line); - } else { + if (m < n) { + fprintf(stderr, "ERROR %d writing to di socket\n", n); return -1; } } - if (m < n) { - fprintf(stderr, "ERROR %d writing to di socket\n", n); - return -1; - } break; case LWS_CALLBACK_RECEIVE: - if (strcmp((const char *)in, "reset") == 0) { - line = copy_line(JSON_EMPTY); - if (line) { - if (list_add(lines, line) == 0) { - lws_callback_on_writable_all_protocol(context, - &protocols[PROTOCOL_MERICA_TERMINAL]); - } else { - free_line(line); - } - } - } else if (strcmp((const char *)in, "close") == 0) { + if (strcmp((const char *)in, "close") == 0) { fprintf(stderr, "closing websocket\n"); lws_close_reason(wsi, LWS_CLOSE_STATUS_GOINGAWAY, (unsigned char *)"seeya", 5); diff --git a/mt_server.h b/mt_server.h index 77d7371..5beb9dd 100644 --- a/mt_server.h +++ b/mt_server.h @@ -19,8 +19,6 @@ #define HTTP_MOUNTPOINT "/" // mountpoint URL #define HTTP_DEFAULT "index.html" // default filename -#define JSON_EMPTY "{\"type\":\"empty\"}" // default message - typedef struct node { char *line; struct node *next;