Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LSubscribeManager.h
00001 /************************************************************************************** 00002 * Copyright (c) 2016, Tomoaki Yamaguchi 00003 * 00004 * All rights reserved. This program and the accompanying materials 00005 * are made available under the terms of the Eclipse Public License v1.0 00006 * and Eclipse Distribution License v1.0 which accompany this distribution. 00007 * 00008 * The Eclipse Public License is available at 00009 * http://www.eclipse.org/legal/epl-v10.html 00010 * and the Eclipse Distribution License is available at 00011 * http://www.eclipse.org/org/documents/edl-v10.php. 00012 * 00013 * Contributors: 00014 * Tomoaki Yamaguchi - initial API and implementation and/or initial documentation 00015 **************************************************************************************/ 00016 00017 #ifndef SUBSCRIBEMANAGER_H_ 00018 #define SUBSCRIBEMANAGER_H_ 00019 00020 #include <stdio.h> 00021 #include <string.h> 00022 #include <time.h> 00023 00024 #include "LMqttsnClientApp.h" 00025 #include "LRegisterManager.h" 00026 #include "LTimer.h" 00027 #include "LTopicTable.h" 00028 00029 using namespace std; 00030 00031 namespace linuxAsyncClient { 00032 00033 typedef struct SubElement{ 00034 TopicCallback callback; 00035 const char* topicName; 00036 uint16_t msgId; 00037 time_t sendUTC; 00038 uint16_t topicId; 00039 uint8_t msgType; 00040 MQTTSN_topicTypes topicType; 00041 uint8_t qos; 00042 00043 int retryCount; 00044 uint8_t done; 00045 00046 SubElement* prev; 00047 SubElement* next; 00048 } SubElement; 00049 00050 /*======================================== 00051 Class LSubscribeManager 00052 =======================================*/ 00053 class LSubscribeManager{ 00054 public: 00055 LSubscribeManager(); 00056 ~LSubscribeManager(); 00057 void onConnect(void); 00058 void subscribe(const char* topicName, TopicCallback onPublish, uint8_t qos); 00059 void subscribe(uint16_t topicId, TopicCallback onPublish, uint8_t qos); 00060 void unsubscribe(const char* topicName); 00061 void unsubscribe(uint16_t topicId); 00062 void responce(const uint8_t* msg); 00063 void checkTimeout(void); 00064 bool isDone(void); 00065 private: 00066 void send(SubElement* elm); 00067 SubElement* getFirstElement(void); 00068 SubElement* getElement(uint16_t msgId); 00069 SubElement* getElement(uint16_t topicId, MQTTSN_topicTypes topicType); 00070 SubElement* getElement(const char* topicName, uint8_t msgType); 00071 SubElement* add(uint8_t msgType, const char* topicName, MQTTSN_topicTypes topicType, uint16_t topicId, uint8_t qos, TopicCallback callback); 00072 void remove(SubElement* elm); 00073 SubElement* _first; 00074 SubElement* _last; 00075 }; 00076 00077 } /* end of namespace */ 00078 #endif /* SUBSCRIBEMANAGER_H_ */
Generated on Wed Jul 13 2022 10:46:02 by
1.7.2