Barracuda Application Server C/C++ Reference
NO
SMQ Struct Reference

Detailed Description

SimpleMQ structure.

#include <SMQ.h>

Public Member Functions

 SMQ (U8 *buf, U16 bufLen)
 Create a SimpleMQ client instance. More...
 
int init (const char *url, U32 *rnd)
 Initiate the SMQ server connection. More...
 
int connect (const char *uid, int uidLen, const char *credentials, U8 credLen, const char *info, int infoLen)
 Connect/establish a persistent SimpleMQ connection. More...
 
void disconnect ()
 Gracefully close the connection. More...
 
 ~SMQ ()
 Terminate a SimpleMQ instance. More...
 
int create (const char *topic)
 Create a topic an fetch the topic ID (tid). More...
 
int createsub (const char *subtopic)
 Create a sub-topic and fetch the subtopic ID. More...
 
int subscribe (const char *topic)
 The response to SMQ_subscribe is asynchronous and returned as status SMQ_SUBACK via SMQ_getMessage. More...
 
int unsubscribe (U32 tid)
 Requests the broker to unsubscribe the server from a topic. More...
 
int publish (const void *data, int len, U32 tid, U32 subtid)
 Publish messages to a topic and optionally to a sub-topic. More...
 
int wrtstr (const char *str)
 Publish a message in chunks and request the broker to assemble the message before publishing to the subscriber(s). More...
 
int write (const void *data, int len)
 Publish a message in chunks and request the broker to assemble the message before publishing to the subscriber(s). More...
 
int pubflush (U32 tid, U32 subtid)
 Flush the internal buffer and request the broker to assemble all stored fragments as one message. More...
 
int observe (U32 tid)
 Request the broker to provide change notification events when the number of subscribers to a specific topic changes. More...
 
int unobserve (U32 tid)
 Stop receiving change notifications for a topic ID or ephemeral topic ID. More...
 
int getMessage (U8 **msg)
 Wait for messages sent from the broker. More...
 
int getMsgSize ()
 Returns the message size, which is SMQ::frameLen - 15. More...
 

Public Attributes

U8 * buf
 The buffer set via the constructor.
 
U32 timeout
 Timeout in milliseconds to wait in functions waiting for server data.
 
U32 clientTid
 Client's unique topic ID.
 
U32 tid
 Topic: set when receiving MSG_PUBLISH from broker.
 
U32 ptid
 Publisher's tid: Set when receiving MSG_PUBLISH from broker.
 
U32 subtid
 Sub-tid: set when receiving MSG_PUBLISH from broker.
 
int status
 Last known error code.
 
U16 frameLen
 The SimpleMQ frame size for the incomming data.
 
U16 bytesRead
 Read frame data using SMQ_getMessage until: frameLen - bytesRead = 0.