aqhome: started rewriting message code, start using new event2 lib.
This commit is contained in:
@@ -15,22 +15,54 @@
|
||||
#include <gwenhywfar/ringbuffer.h>
|
||||
|
||||
#define AQH_MSG_READER_RINGBUFFER_SIZE 1024
|
||||
#define AQH_MSG_READER_HEADERBUFFER_SIZE 4
|
||||
#define AQH_MSG_READER_HEADERBUFFER_SIZE 32
|
||||
|
||||
|
||||
typedef struct AQH_MSG_READER AQH_MSG_READER;
|
||||
|
||||
/**
|
||||
* Read data for a message from the internal ring buffer.
|
||||
*
|
||||
* @return 1 if something has been done, 0 if not, negative on error
|
||||
* @param o object (THIS)
|
||||
*/
|
||||
typedef int (*AQH_MSG_READER_READMSG_FN)(AQH_OBJECT *o);
|
||||
|
||||
|
||||
|
||||
struct AQH_MSG_READER {
|
||||
int fdSocket;
|
||||
AQH_OBJECT *fdObject;
|
||||
GWEN_RINGBUFFER *ringBuffer;
|
||||
|
||||
int bytesReceived;
|
||||
int bytesLeft;
|
||||
uint8_t headerBuffer[AQH_MSG_READER_HEADERBUFFER_SIZE];
|
||||
uint8_t *currentMsgBuf;
|
||||
|
||||
uint32_t flags;
|
||||
uint64_t timestamp;
|
||||
|
||||
AQH_OBJECT *fdObject;
|
||||
|
||||
AQH_MSG_READER_READMSG_FN readMsgFn;
|
||||
};
|
||||
|
||||
|
||||
AQH_OBJECT *AQH_MsgReader_new(AQH_EVENT_LOOP *eventLoop, AQH_OBJECT *fdObject);
|
||||
|
||||
AQH_MSG_READER *AQH_MsgReader_GetData(const AQH_OBJECT *o);
|
||||
int AQH_MsgReader_ReadRemainderFromRingbuffer(AQH_OBJECT *o);
|
||||
|
||||
int AQH_MsgReader_ReadMsg(AQH_OBJECT *o);
|
||||
AQH_MSG_READER_READMSG_FN AQH_MsgReader_SetReadMsgFn(AQH_OBJECT *o, AQH_MSG_READER_READMSG_FN f);
|
||||
|
||||
|
||||
uint32_t AQH_MsgReader_GetFlags(const AQH_OBJECT *o);
|
||||
void AQH_MsgReader_SetFlags(AQH_OBJECT *o, uint32_t f);
|
||||
void AQH_MsgReader_AddFlags(AQH_OBJECT *o, uint32_t f);
|
||||
void AQH_MsgReader_SubFlags(AQH_OBJECT *o, uint32_t f);
|
||||
|
||||
void AQH_MsgReader_StartSkipping(AQH_OBJECT *o);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user