summaryrefslogtreecommitdiffstats
path: root/subscribe.h
blob: 75818c768cf2bdec961f70263072a310a8ab83ad (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
31
32
33
34
35
36
37
38
39
#ifndef foosubscribehfoo
#define foosubscribehfoo

typedef struct _flxSubscription flxSubscription;

#include "llist.h"
#include "server.h"

typedef enum {
    FLX_SUBSCRIPTION_NEW,
    FLX_SUBSCRIPTION_REMOVE,
    FLX_SUBSCRIPTION_CHANGE
} flxSubscriptionEvent;

typedef void (*flxSubscriptionCallback)(flxSubscription *s, flxRecord *record, gint interface, guchar protocol, flxSubscriptionEvent event, gpointer userdata);

struct _flxSubscription {
    flxServer *server;
    flxKey *key;
    gint interface;
    guchar protocol;
    gint n_query;
    guint sec_delay;

    flxTimeEvent *time_event;

    flxSubscriptionCallback callback;
    gpointer userdata;

    FLX_LLIST_FIELDS(flxSubscription, subscriptions);
    FLX_LLIST_FIELDS(flxSubscription, by_key);
};

flxSubscription *flx_subscription_new(flxServer *s, flxKey *key, gint interface, guchar protocol, flxSubscriptionCallback callback, gpointer userdata);
void flx_subscription_free(flxSubscription *s);

void flx_subscription_notify(flxServer *s, flxInterface *i, flxRecord *record, flxSubscriptionEvent event);

#endif