47#define ENABLE_HTTPS_PROXY
48#define ENABLE_SOCKS_PROXY
51#if defined(ENABLE_HTTPS_PROXY) || defined(ENABLE_SOCKS_PROXY)
71#define SMQE_BUF_OVERFLOW -10000
75#define SMQE_ONACK_DENIED -10000
79#define SMQE_INVALID_URL -10002
83#define SMQE_PROTOCOL_ERROR -10003
87#define SMQE_DISCONNECT -10004
92#define SMQE_PONGTIMEOUT -10005
113#define SMQ_SUBACK -20000
125#define SMQ_CREATEACK -20001
134#define SMQ_CREATESUBACK -20002
142#define SMQ_SUBCHANGE -20003
146#define SMQ_TIMEOUT -20004
151#define SMQSTR(str) str, (sizeof(str)-1)
174 S32 pingTmoCounter,pingTmo;
204 int connect(
const char* uid,
int uidLen,
const char* credentials,
205 U8 credLen,
const char* info,
int infoLen,
206 U16 maxTlsFrameSize);
224 int create(
const char* topic);
258 int wrtstr(
const char* str);
264 int write(
const void* data,
int len);
322#define SharkMQ_setProxy(o, proxyMA) (o)->proxy=proxyMA
329#define SharkMQ_setCtx(o, ctx) SOCKET_constructor(&(o)->sock, ctx)
338#define SharkMQ_getSendBufPtr(o) (SharkSslCon_getEncBufPtr((o)->scon) + 15)
346#define SharkMQ_getSendBufSize(o) (SharkSslCon_getEncBufSize((o)->scon) - 15)
408 const char* credentials, U8 credLen,
409 const char* info,
int infoLen,
410 U16 maxTlsFrameSize);
591#define SharkMQ_getMsgSize(o) ((o)->frameLen-15)
607 const char* credentials,
608 U8 credLen,
const char* info,
int infoLen,
609 U16 maxTlsFrameSize) {
611 this,uid,uidLen,credentials,credLen,info,infoLen,maxTlsFrameSize);
int SharkMQ_create(SharkMQ *o, const char *topic)
Create a topic an fetch the topic ID (tid).
int SharkMQ_write(SharkMQ *o, const void *data, int len)
Publish a message in chunks and request the broker to assemble the message before publishing to the s...
int SharkMQ_subscribe(SharkMQ *o, const char *topic)
Subscribe to topic.
int SharkMQ_getMessage(SharkMQ *o, U8 **msg)
Wait for messages sent from the broker.
int SharkMQ_publish(SharkMQ *o, const void *data, int len, U32 tid, U32 subtid)
Publish messages to a topic and optionally to a sub-topic.
int SharkMQ_createsub(SharkMQ *o, const char *subtopic)
Create a sub-topic and fetch the subtopic ID.
int SharkMQ_connect(SharkMQ *o, const char *uid, int uidLen, const char *credentials, U8 credLen, const char *info, int infoLen, U16 maxTlsFrameSize)
Connect/establish a persistent SMQ connection.
#define SharkMQ_getMsgSize(o)
Returns the message size, which is SharkMQ::frameLen - 15.
Definition: SMQ.h:591
void SharkMQ_constructor(SharkMQ *o, U8 *buf, U16 bufLen)
Create a secure SMQ client instance.
int SharkMQ_unsubscribe(SharkMQ *o, U32 tid)
Requests the broker to unsubscribe the client from a topic.
void SharkMQ_disconnect(SharkMQ *o)
Gracefully close the connection.
int SharkMQ_unobserve(SharkMQ *o, U32 tid)
Stop receiving change notifications for a topic ID or ephemeral topic ID.
int SharkMQ_wrtstr(SharkMQ *o, const char *str)
Publish a message in chunks and request the broker to assemble the message before publishing to the s...
int SharkMQ_pubflush(SharkMQ *o, U32 tid, U32 subtid)
Flush the internal buffer and request the broker to assemble all stored fragments as one message.
int SharkMQ_observe(SharkMQ *o, U32 tid)
Request the broker to provide change notification events when the number of subscribers to a specific...
int SharkMQ_init(SharkMQ *o, SharkSslCon *scon, const char *url, U32 *rnd)
Initiate the SharkMQ server connection.
void SharkMQ_destructor(SharkMQ *o)
Terminate an SMQ instance.
int init(SharkSslCon *scon, const char *url, U32 *rnd)
Initiate the SMQ server connection.
Definition: SMQ.h:602
int getMsgSize()
Returns the message size, which is SMQ::frameLen - 15.
Definition: SMQ.h:666
int createsub(const char *subtopic)
Create a sub-topic and fetch the subtopic ID.
Definition: SMQ.h:626
int unsubscribe(U32 tid)
Requests the broker to unsubscribe the server from a topic.
Definition: SMQ.h:634
int publish(const void *data, int len, U32 tid, U32 subtid)
Publish messages to a topic and optionally to a sub-topic.
Definition: SMQ.h:638
struct SharkMQ SharkMQ
SharkMQ structure.
int wrtstr(const char *str)
Publish a message in chunks and request the broker to assemble the message before publishing to the s...
Definition: SMQ.h:642
SharkMQ(U8 *buf, U16 bufLen)
Create a secure SMQ client instance.
Definition: SMQ.h:598
int pubflush(U32 tid, U32 subtid)
Flush the internal buffer and request the broker to assemble all stored fragments as one message.
Definition: SMQ.h:650
int write(const void *data, int len)
Publish a message in chunks and request the broker to assemble the message before publishing to the s...
Definition: SMQ.h:646
int getMessage(U8 **msg)
Wait for messages sent from the broker.
Definition: SMQ.h:662
int subscribe(const char *topic)
The response to SharkMQ_subscribe is asynchronous and returned as status SMQ_SUBACK via SharkMQ_getMe...
Definition: SMQ.h:630
int create(const char *topic)
Create a topic an fetch the topic ID (tid).
Definition: SMQ.h:622
~SharkMQ()
Terminate an SMQ instance.
Definition: SMQ.h:618
int connect(const char *uid, int uidLen, const char *credentials, U8 credLen, const char *info, int infoLen, U16 maxTlsFrameSize)
Connect/establish a persistent SMQ connection.
Definition: SMQ.h:606
int observe(U32 tid)
Request the broker to provide change notification events when the number of subscribers to a specific...
Definition: SMQ.h:654
void disconnect()
Gracefully close the connection.
Definition: SMQ.h:614
int unobserve(U32 tid)
Stop receiving change notifications for a topic ID or ephemeral topic ID.
Definition: SMQ.h:658
struct SharkSslCon SharkSslCon
SharkSslCon is an opaque handle returned by function SharkSsl_createCon.
Definition: SharkSSL.h:553
#define SOCKET
Infinite wait time option for socket read functions.
Definition: selib.h:102
SharkMQ structure.
Definition: SMQ.h:156
U32 clientTid
Client's unique topic ID.
Definition: SMQ.h:175
U32 tid
Topic: set when receiving MSG_PUBLISH from broker.
Definition: SMQ.h:176
U16 bytesRead
Read frame data using SharkMQ_getMessage until: frameLen-bytesRead = 0.
Definition: SMQ.h:183
U16 frameLen
The SMQ frame size for the incomming data.
Definition: SMQ.h:181
U32 ptid
Publisher's tid: Set when receiving MSG_PUBLISH from broker.
Definition: SMQ.h:177
int status
Last known error code.
Definition: SMQ.h:179
U32 subtid
Sub-tid: set when receiving MSG_PUBLISH from broker.
Definition: SMQ.h:178
U32 timeout
Timeout in milliseconds to wait in functions waiting for server data.
Definition: SMQ.h:173