///
/**
Copyright (C) 2019, IAConnects Technology Limited
All Rights Reserved
ALL INFORMATION CONTAINED HEREIN IS, AND REMAINS
THE PROPERTY OF IACONNECTS TECHNOLOGY LIMITED AND ITS SUPPLIERS,
IF ANY. THE INTELLECTUAL AND TECHNICAL CONCEPTS CONTAINED
HEREIN ARE PROPRIETARY TO IACONNECTS TECHNOLOGY LIMITED
AND ITS SUPPLIERS AND ARE PROTECTED BY TRADE SECRET OR COPYRIGHT LAW.
DISSEMINATION OF THIS INFORMATION OR REPRODUCTION OF THIS MATERIAL
IS STRICTLY FORBIDDEN UNLESS PRIOR WRITTEN PERMISSION IS OBTAINED
FROM IACONNECTS TECHNOLOGY LIMITED.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
**/
import { EventEmitter } from "events";
export interface IMQTTConfig {
url: string;
port: number;
useTLS: boolean;
sid: string;
psk: string;
keepAlive: number;
reconnectPeriod: number;
slowReconnectPeriod: number;
}
export declare class MQTTGateway extends EventEmitter {
private config;
private mqttClient;
private slowReconnectCounter;
private reconnectTimeout;
hubID: string;
constructor(config: IMQTTConfig);
/**
* Get the state of the MQTT connection
* @returns true if connected to the IBM IoT cloud, else false
*/
isConnected(): boolean;
/**
* Connect to the IBM Iot cloud
* @returns A Promise which resolves if a connection is established, or rejects with the error if a connection fails
*/
connect(): Promise;
/**
* Disconnect from the IBM Iot cloud
* @param {boolean} [force = true] - Set true to force an immediate disconnects or false to wait for all
* pending messages to complete before disconnecting
* @returns A Promise which resolves when the connection has ended
*/
disconnect(force?: boolean): Promise;
/**
* Publish a signed message to the gateway
* @param {string} topic - the message topic
* @param {*} payload - the message payload
* @memberof MQTTGateway
*/
publishSignedMessage(topic: string, payload: any): void;
/**
* Force a reconnect if the connection is down for too long
*/
private _reconnect;
/**
* After receiving the registration message publish the object list to the hub
* @private
* @param {string} hubID - the MobiusFlow hub ID passed back in the registration message
* @memberof MQTTGateway
*/
private publishObjectListToHub;
}