libjapi  0.3.2
Universal JSON API Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
japi_pushsrv.h
Go to the documentation of this file.
1 
34 #ifndef __JAPI_PUSHSRV_H__
35 #define __JAPI_PUSHSRV_H__
36 
37 #include <json-c/json.h>
38 #include <stdbool.h>
39 #include <pthread.h>
40 
41 #include "japi.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 struct __japi_pushsrv_context; /* Tell routine there is a struct to be defined */
48 
52 typedef void (*japi_pushsrv_routine)(struct __japi_pushsrv_context *psc);
53 
60 typedef struct __japi_pushsrv_context {
61  char* pushsrv_name;
62  pthread_t thread_id;
64  volatile bool enabled;
65  pthread_mutex_t lock;
66  struct __japi_client *clients;
67  struct __japi_pushsrv_context *next;
68  void *userptr;
70 
81 japi_pushsrv_context* japi_pushsrv_register(japi_context *ctx, const char *pushsrv_name);
82 
97 
108 int japi_pushsrv_sendmsg(japi_pushsrv_context *psc, json_object *jmsg);
109 
121 
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 
137 #endif /* __JAPI_PUSHSRV_H__ */
japi_pushsrv_routine routine
Definition: japi_pushsrv.h:63
void(* japi_pushsrv_routine)(struct __japi_pushsrv_context *psc)
JAPI push service routine.
Definition: japi_pushsrv.h:52
japi_pushsrv_context * japi_pushsrv_register(japi_context *ctx, const char *pushsrv_name)
Register a JAPI push service.
Definition: japi_pushsrv.c:309
int japi_pushsrv_sendmsg(japi_pushsrv_context *psc, json_object *jmsg_data)
Send messages to all subscribed clients.
Definition: japi_pushsrv.c:446
pthread_t thread_id
Definition: japi_pushsrv.h:62
pthread_mutex_t lock
Definition: japi_pushsrv.h:65
int japi_pushsrv_destroy(japi_context *ctx, japi_pushsrv_context *psc)
Remove push service context from japi context, unsubscribe for all clients and free memory...
Definition: japi_pushsrv.c:367
void * userptr
Definition: japi_pushsrv.h:68
JAPI context struct.
Definition: japi.h:52
int japi_pushsrv_stop(japi_pushsrv_context *psc)
Stop push service routine.
Definition: japi_pushsrv.c:563
char * pushsrv_name
Definition: japi_pushsrv.h:61
volatile bool enabled
Definition: japi_pushsrv.h:64
JAPI push service context.
Definition: japi_pushsrv.h:60
struct __japi_pushsrv_context * next
Definition: japi_pushsrv.h:67
int japi_pushsrv_start(japi_pushsrv_context *psc, japi_pushsrv_routine routine)
Start push service routine.
Definition: japi_pushsrv.c:534
Universal JSON API library.
struct __japi_client * clients
Definition: japi_pushsrv.h:66