version 1.1.2.1, 2012/01/27 08:28:40
|
version 1.1.2.2, 2012/01/27 15:12:27
|
Line 2
|
Line 2
|
#define __MQTTAPI_H |
#define __MQTTAPI_H |
|
|
|
|
|
#include "aitmqtt.h" |
|
|
|
|
|
/* MQTT server structure & hooks */ |
|
|
|
/* MQTT command callback. 1st argument is (mqtt_srv_t*) server handle */ |
|
typedef int (*mqtt_cb_t)(void* /*mqtt_srv_t**/, void *); |
|
typedef struct { |
|
mqtt_cb_t cmds[MQTT_TYPE_MAX]; |
|
|
|
int sock; |
|
mqtt_msg_t *buf; |
|
} mqtt_srv_t; |
|
#define mqtt_srv_setCmd(x, _cmd, _func) (assert((x)), (x)->cmds[(_cmd)] = (_func)) |
|
#define mqtt_srv_getCmd(x, _cmd) (assert((x)), (x)->cmds[(_cmd)]) |
|
|
|
|
|
/* |
|
* mqtt_srv_Init() Init server side actor |
|
* |
|
* @sock = Client socket from accept() |
|
* @buf = Message buffer |
|
* return: NULL error or !=NULL allocated server handle |
|
*/ |
|
mqtt_srv_t *mqtt_srv_Init(int sock, mqtt_msg_t * __restrict buf); |
|
/* |
|
* mqtt_srv_Fini() Finish MQTT server side support |
|
* |
|
* @psrv = Server handle |
|
* return: none |
|
*/ |
|
void mqtt_srv_Fini(mqtt_srv_t ** __restrict psrv); |
|
/* |
|
* mqtt_srv_Dispatch() MQTT server dispatcher |
|
* |
|
* @srv = Server handle |
|
* @arg = Argument pass to command callback |
|
* return: -1 error or 0 ok |
|
*/ |
|
int mqtt_srv_Dispatch(mqtt_srv_t * __restrict srv, void *arg); |
|
|
|
|
#endif |
#endif |