Jack Hansdampf / mbed-mqtt-GSOE1

Dependents:   ESP8266MQTT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MQTTSNGWClientList.h Source File

MQTTSNGWClientList.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  *    Tieto Poland Sp. z o.o. - Gateway improvements
00016  **************************************************************************************/
00017 
00018 #ifndef MQTTSNGATEWAY_SRC_MQTTSNGWCLIENTLIST_H_
00019 #define MQTTSNGATEWAY_SRC_MQTTSNGWCLIENTLIST_H_
00020 
00021 #include "MQTTSNGWClient.h"
00022 #include "MQTTSNGateway.h"
00023 
00024 namespace MQTTSNGW
00025 {
00026 #define TRANSPEARENT_TYPE 0
00027 #define QOSM1PROXY_TYPE 1
00028 #define AGGREGATER_TYPE 2
00029 #define FORWARDER_TYPE  3
00030 
00031 class Client;
00032 
00033 /*=====================================
00034  Class ClientList
00035  =====================================*/
00036 class ClientList
00037 {
00038 public:
00039     ClientList();
00040     ~ClientList();
00041 
00042     void initialize(bool aggregate);
00043     void setClientList(int type);
00044     void setPredefinedTopics(bool aggregate);
00045     void erase(Client*&);
00046     Client* createClient(SensorNetAddress* addr, MQTTSNString* clientId,int type);
00047     Client* createClient(SensorNetAddress* addr, MQTTSNString* clientId, bool unstableLine, bool secure, int type);
00048     bool createList(const char* fileName, int type);
00049     Client* getClient(SensorNetAddress* addr);
00050     Client* getClient(MQTTSNString* clientId);
00051     Client* getClient(int index);
00052     uint16_t getClientCount(void);
00053     Client* getClient(void);
00054     bool isAuthorized();
00055 
00056 private:
00057     bool readPredefinedList(const char* fileName, bool _aggregate);
00058     Gateway* _gateway {nullptr};
00059     Client* createPredefinedTopic( MQTTSNString* clientId, string topicName, uint16_t toipcId, bool _aggregate);
00060     Client* _firstClient;
00061     Client* _endClient;
00062     Mutex _mutex;
00063     uint16_t _clientCnt;
00064     bool _authorize {false};
00065 };
00066 
00067 
00068 }
00069 
00070 
00071 
00072 #endif /* MQTTSNGATEWAY_SRC_MQTTSNGWCLIENTLIST_H_ */