コード例 #1
0
int MQTTProtocol_startGet(Clients* getclient, Get* get, int qos, int retained, Messages** m)
{
	Get p = *get;
	int rc = 0;

	FUNC_ENTRY;
#if 0
	if (qos > 0)
	{
		p.msgId = get->msgId = MQTTProtocol_assignMsgId(getclient);
		*mm = MQTTProtocol_createMessage(get, mm, qos, retained);
		ListAppend(pubclient->outboundMsgs, *mm, (*mm)->len);
		/* we change these pointers to the saved message location just in case the packet could not be written
		entirely; the socket buffer will use these locations to finish writing the packet */
		p.payload = (*mm)->publish->payload;
		p.topic = (*mm)->publish->topic;
	}
	rc = MQTTProtocol_startPublishCommon(pubclient, &p, qos, retained);
#else
	get->msgId = MQTTProtocol_assignMsgId(getclient);
	rc = MQTTPacket_send_get(get, 0, qos, retained, &getclient->net, getclient->clientID);
#endif
	FUNC_EXIT_RC(rc);
	return rc;

}
コード例 #2
0
/**
 * Start a new publish exchange.  Store any state necessary and try to send the packet
 * @param pubclient the client to send the publication to
 * @param publish the publication data
 * @param qos the MQTT QoS to use
 * @param retained boolean - whether to set the MQTT retained flag
 * @param mm - pointer to the message to send
 * @return the completion code
 */
int MQTTProtocol_startPublish(Clients* pubclient, Publish* publish, int qos, int retained, Messages** mm)
{
	Publish p = *publish;
	int rc = 0;

	FUNC_ENTRY;
	if (qos > 0)
	{
		*mm = MQTTProtocol_createMessage(publish, mm, qos, retained);
		ListAppend(pubclient->outboundMsgs, *mm, (*mm)->len);
		/* we change these pointers to the saved message location just in case the packet could not be written
		entirely; the socket buffer will use these locations to finish writing the packet */
		p.payload = (*mm)->publish->payload;
		p.topic = (*mm)->publish->topic;
	}
	rc = MQTTProtocol_startPublishCommon(pubclient, &p, qos, retained);
	FUNC_EXIT_RC(rc);
	return rc;
}
コード例 #3
0
ファイル: MQTTProtocolClient.c プロジェクト: bluerover/rsmb
/**
 * Start a new publication exchange for a previously queued message.
 * @param pubclient the client to send the publication to
 * @param m pointer to the message to send
 * @return the completion code
 */
int MQTTProtocol_startQueuedPublish(Clients* pubclient, Messages* m)
{
	int rc = 0;
	Publish publish;

	FUNC_ENTRY;
	if (m->qos > 0)
	{
		m->msgid = MQTTProtocol_assignMsgId(pubclient);
		ListAppend(pubclient->outboundMsgs, m, m->len);
	}
	publish.header.byte = 0;
	publish.header.bits.qos = m->qos;
	publish.header.bits.retain = m->retain;
	publish.header.bits.type = PUBLISH;
	publish.msgId = m->msgid;
	publish.payload = m->publish->payload;
	publish.payloadlen = m->publish->payloadlen;
	publish.topic = m->publish->topic;
	rc = MQTTProtocol_startPublishCommon(pubclient, &publish, m->qos, m->retain);
	FUNC_EXIT_RC(rc);
	return rc;
}