当前位置: 首页>>代码示例>>C++>>正文


C++ Topic::getTopicName方法代码示例

本文整理汇总了C++中Topic::getTopicName方法的典型用法代码示例。如果您正苦于以下问题:C++ Topic::getTopicName方法的具体用法?C++ Topic::getTopicName怎么用?C++ Topic::getTopicName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Topic的用法示例。


在下文中一共展示了Topic::getTopicName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createTopic

uint16_t Topics::createTopic(string* topic){
    if (!getTopic(topic)){
        if ( _cnt < MAX_TOPIC_COUNT){
        	Topic* tp = new Topic();
        	tp->setTopicName(*topic);
        	if(tp->getTopicLength() == 2){
        		uint16_t id = getUint16((uint8_t*)tp->getTopicName());
        		tp->setTopicId(id);
        	}else{
        		tp->setTopicId(getNextTopicId());
        	}
        	_topics.push_back(tp);
        	_cnt++;
        	return _nextTopicId;
        }else{
        	return 0;
        }
    }else{
    	return getTopicId(topic);
    }
}
开发者ID:cxcco,项目名称:MQTT-S-Gateway,代码行数:21,代码来源:Topics.cpp

示例2: handleSnPublish

/*-------------------------------------------------------
 *               Upstream MQTTSnPublish
 -------------------------------------------------------*/
void GatewayControlTask::handleSnPublish(Event* ev, ClientNode* clnode, MQTTSnMessage* msg){

	printf(BLUE_FORMAT2, currentDateTime(), "PUBLISH", LEFTARROW, clnode->getNodeId()->c_str(), msgPrint(msg));

	MQTTSnPublish* sPublish = new MQTTSnPublish();
	MQTTPublish* mqMsg = new MQTTPublish();
	sPublish->absorb(msg);

	Topic* tp = clnode->getTopics()->getTopic(sPublish->getTopicId());

	if(tp || ((sPublish->getFlags() && MQTTSN_TOPIC_TYPE) == MQTTSN_TOPIC_TYPE_SHORT)){
		if(tp){
			mqMsg->setTopic(tp->getTopicName());
		}else{
			string str;
			mqMsg->setTopic(sPublish->getTopic(&str));
		}
		if(sPublish->getMsgId()){
			MQTTSnPubAck* sPuback = new MQTTSnPubAck();
			sPuback->setMsgId(sPublish->getMsgId());
			sPuback->setTopicId(sPublish->getTopicId());
			if(clnode->getWaitedPubAck()){
				delete clnode->getWaitedPubAck();
			}
			clnode->setWaitedPubAck(sPuback);

			mqMsg->setMessageId(sPublish->getMsgId());
		}

		mqMsg->setQos(sPublish->getQos());

		if(sPublish->getFlags() && MQTTSN_FLAG_DUP){
			mqMsg->setDup();
		}
		if(sPublish->getFlags() && MQTTSN_FLAG_RETAIN){
			mqMsg->setRetain();
		}

		mqMsg->setPayload(sPublish->getData() , sPublish->getDataLength());

		clnode->setBrokerSendMessage(mqMsg);
		Event* ev1 = new Event();
		ev1->setBrokerSendEvent(clnode);
		_res->getBrokerSendQue()->post(ev1);

	}else{
		if(sPublish->getMsgId()){
			MQTTSnPubAck* sPuback = new MQTTSnPubAck();
			sPuback->setMsgId(sPublish->getMsgId());
			sPuback->setTopicId(sPublish->getTopicId());
			sPuback->setReturnCode(MQTTSN_RC_REJECTED_INVALID_TOPIC_ID);

			clnode->setClientSendMessage(sPuback);

			Event* ev1 = new Event();
			ev1->setClientSendEvent(clnode);
			printf(BLUE_FORMAT1, currentDateTime(), "PUBACK", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(sPuback));

			_res->getClientSendQue()->post(ev1);  // Send PubAck INVALID_TOPIC_ID
		}
	}
	delete sPublish;
}
开发者ID:comrit,项目名称:MQTT-SN,代码行数:66,代码来源:GatewayControlTask.cpp


注:本文中的Topic::getTopicName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。