]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/commitdiff
Do not generate "empty" messages
authorMichal Sojka <michal.sojka@cvut.cz>
Thu, 16 Aug 2018 21:48:47 +0000 (23:48 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Thu, 16 Aug 2018 21:48:47 +0000 (23:48 +0200)
They were probably not used for anything useful. They cluttered logs
and made debugging harder.

mt_server.c
mt_server.h

index c683c7528f1cdac93738b6868c3f40d5cd54b131..ee80d87a7f73a9ac251653369b02339963be2b76 100644 (file)
@@ -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);
index 77d737102d1cf127acfdb660c3744dccb5d9466b..5beb9dd8b1da209a0d1d5b5c2f54bfa3c25263a5 100644 (file)
@@ -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;