  
    /* The non-compressed case */
    whole_packet_len = len_read;
-@@ -488,8 +490,39 @@
+@@ -488,8 +490,35 @@
      return NULL;
    }
  

 
 /* Used in the network protocol. */
-#define MAX_LEN_PACKET   4096
+#define MAX_LEN_PACKET    65536
 #define MAX_LEN_CAPSTR    512
 #define MAX_LEN_PASSWORD  512 /* do not change this under any circumstances */
 

+  /* Parse JSON packet. */
+  json_error_t error;
+
+  pc->json_packet = json_loadb((char*)pc->buffer->data + 4, whole_packet_len, 0, &error);
+
+  memmove(pc->buffer->data, pc->buffer->data, pc->buffer->ndata);
+  pc->buffer->ndata = 0;
