aboutsummaryrefslogtreecommitdiffstats
path: root/src/TestStatsServer.cpp
blob: 0d86195b7a994c648ea0b0f1f8f67967bdfabee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include "StatsServer.h"

#define NUMOF(x) (sizeof(x) / sizeof(*x))

int main(int argc, char **argv)
{
    int stats_example[] = {25, 24, 22, 21, 56, 56, 54, 53, 51, 45, 42, 39, 34, 30, 24, 15, 8, 4, 1, 0};
    StatsServer serv(2720);

    serv.registerInput("foo");
    while (true) {
        for (int i = 0; i < NUMOF(stats_example); i++) {
            usleep(400000);
            serv.notifyBuffer("foo", stats_example[i]);
            fprintf(stderr, "give %d\n", stats_example[i]);

            if (stats_example[i] == 0) {
                serv.notifyUnderrun("foo");
            }

            if (stats_example[i] == 56) {
                serv.notifyOverrun("foo");
            }
        }
    }

    return 0;
}