47#define ENABLE_HTTPS_PROXY
48#define ENABLE_SOCKS_PROXY
51#if defined(ENABLE_HTTPS_PROXY) || defined(ENABLE_SOCKS_PROXY)
72#define SMQE_BUF_OVERFLOW -10000
76#define SMQE_ONACK_DENIED -10000
80#define SMQE_INVALID_URL -10002
84#define SMQE_PROTOCOL_ERROR -10003
88#define SMQE_DISCONNECT -10004
93#define SMQE_PONGTIMEOUT -10005
97#define SMQE_TLS_AUTH_FAILED -10006
118#define SMQ_SUBACK -20000
130#define SMQ_CREATEACK -20001
139#define SMQ_CREATESUBACK -20002
147#define SMQ_SUBCHANGE -20003
152#define SMQ_TIMEOUT -20004
157#define SMQSTR(str) str, (sizeof(str)-1)
210 int connect(
const char* uid,
int uidLen,
const char* credentials,
211 U8 credLen,
const char* info,
int infoLen,
212 U16 maxTlsFrameSize);
230 int create(
const char* topic);
264 int wrtstr(
const char* str);
270 int write(
const void* data,
int len);
329#define SharkMQ_setProxy(o, proxyMA) (o)->proxy=proxyMA
336#define SharkMQ_setCtx(o, ctx) SOCKET_constructor(&(o)->sock, ctx)
345#define SharkMQ_getSendBufPtr(o) (SharkSslCon_getEncBufPtr((o)->scon) + 15)
353#define SharkMQ_getSendBufSize(o) (SharkSslCon_getEncBufSize((o)->scon) - 15)
424 const char* credentials, U8 credLen,
425 const char* info,
int infoLen,
426 U16 maxTlsFrameSize);
613#define SharkMQ_getMsgSize(o) ((o)->frameLen-15)
629 const char* credentials,
630 U8 credLen,
const char* info,
int infoLen,
631 U16 maxTlsFrameSize) {
633 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:613
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:624
int getMsgSize()
Returns the message size, which is SMQ::frameLen - 15.
Definition: SMQ.h:688
int createsub(const char *subtopic)
Create a sub-topic and fetch the subtopic ID.
Definition: SMQ.h:648
int unsubscribe(U32 tid)
Requests the broker to unsubscribe the server from a topic.
Definition: SMQ.h:656
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:660
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:664
SharkMQ(U8 *buf, U16 bufLen)
Create a secure SMQ client instance.
Definition: SMQ.h:620
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:672
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:668
int getMessage(U8 **msg)
Wait for messages sent from the broker.
Definition: SMQ.h:684
int subscribe(const char *topic)
The response to SharkMQ_subscribe is asynchronous and returned as status SMQ_SUBACK via SharkMQ_getMe...
Definition: SMQ.h:652
int create(const char *topic)
Create a topic an fetch the topic ID (tid).
Definition: SMQ.h:644
~SharkMQ()
Terminate an SMQ instance.
Definition: SMQ.h:640
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:628
int observe(U32 tid)
Request the broker to provide change notification events when the number of subscribers to a specific...
Definition: SMQ.h:676
void disconnect()
Gracefully close the connection.
Definition: SMQ.h:636
int unobserve(U32 tid)
Stop receiving change notifications for a topic ID or ephemeral topic ID.
Definition: SMQ.h:680
struct SharkSslCon SharkSslCon
SharkSslCon is an opaque handle returned by function SharkSsl_createCon.
Definition: SharkSSL.h:495
#define SOCKET
Infinite wait time option for socket read functions.
Definition: selib.h:103
Optional proxy configuration for the SharkMQ example library.
Caller-owned proxy settings with borrowed string pointers.
Definition: proxy.h:103
SharkMQ structure.
Definition: SMQ.h:162
SharkSslCon * scon
Definition: SMQ.h:164
U8 * sharkBuf
Definition: SMQ.h:166
S32 pingTmo
Definition: SMQ.h:180
U16 bufIx
Definition: SMQ.h:173
SOCKET sock
Definition: SMQ.h:163
U16 sharkBufLen
Definition: SMQ.h:169
S32 pingTmoCounter
Definition: SMQ.h:180
U16 bufLen
Definition: SMQ.h:172
U8 * buf
Definition: SMQ.h:167
U32 clientTid
Client's unique topic ID.
Definition: SMQ.h:181
U16 sendBufIx
Definition: SMQ.h:186
U32 tid
Topic: set when receiving MSG_PUBLISH from broker.
Definition: SMQ.h:182
U16 bytesRead
Read frame data using SharkMQ_getMessage until: frameLen-bytesRead = 0.
Definition: SMQ.h:189
U16 frameLen
The SMQ frame size for the incomming data.
Definition: SMQ.h:187
U32 ptid
Publisher's tid: Set when receiving MSG_PUBLISH from broker.
Definition: SMQ.h:183
int status
Last known error code.
Definition: SMQ.h:185
U32 subtid
Sub-tid: set when receiving MSG_PUBLISH from broker.
Definition: SMQ.h:184
U32 timeout
Timeout in milliseconds to wait in functions waiting for server data.
Definition: SMQ.h:179
U16 sharkBufIx
Definition: SMQ.h:170
Proxy * proxy
Optional borrowed settings; assign after construction and before init.
Definition: SMQ.h:191