gluon/package/gluon-mesh-babel/src/neighbours-babel.c
Christof Schulze 6d64057536 gluon-mesh-babel: neighbours-babel: adjust to libbabelhelper interface
specify command 'dump' for now until babeld supports filtering
2019-09-29 22:44:39 +02:00

32 lines
685 B
C

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <json-c/json.h>
#include <libbabelhelper/babelhelper.h>
#include "handle_neighbour.h"
int main(void) {
struct json_object *neighbours;
printf("Content-type: text/event-stream\n\n");
fflush(stdout);
struct babelhelper_ctx bhelper_ctx = {};
while (1) {
neighbours = json_object_new_object();
if (!neighbours)
continue;
bhelper_ctx.debug = false;
babelhelper_readbabeldata(&bhelper_ctx, "dump", (void*)neighbours, handle_neighbour);
printf("data: %s\n\n", json_object_to_json_string(neighbours));
fflush(stdout);
json_object_put(neighbours);
neighbours = NULL;
sleep(10);
}
return 0;
}