summaryrefslogtreecommitdiffstats
path: root/src/server/rpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/rpc.c')
-rw-r--r--src/server/rpc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/server/rpc.c b/src/server/rpc.c
new file mode 100644
index 0000000..b2dc088
--- /dev/null
+++ b/src/server/rpc.c
@@ -0,0 +1,18 @@
+#include <unistd.h>
+#include <jansson.h>
+
+#include "rpc.h"
+
+void rpc_sendStatsJson(int sock)
+{
+ int receivedBytes = 0;
+ int sentBytes = 1;
+ json_t *statisticsJson = json_pack( "{sisi}", "receivedBytes", receivedBytes, "sentBytes", sentBytes );
+ char* jsonString = json_dumps(statisticsJson, 0);
+ char bla[500];
+ snprintf(bla, sizeof bla, "HTTP/1.1 200 OK\r\nConnection: Close\r\nContent-Length: %d\r\nContent-Type: application/json\r\n\r\n", (int)strlen(jsonString));
+ write( sock, bla, strlen(bla) );
+ int n = write( sock, jsonString, strlen(jsonString));
+ json_decref(statisticsJson);
+ free(jsonString);
+}