/*
M2Mqtt - MQTT Client Library for .Net
Copyright (c) 2014, Paolo Patierno, All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
*/
namespace uPLibrary.Networking.M2Mqtt
{
///
/// Settings class for the MQTT broker
///
public class MqttSettings
{
// default port for MQTT protocol
public const int MQTT_BROKER_DEFAULT_PORT = 1883;
public const int MQTT_BROKER_DEFAULT_SSL_PORT = 8883;
// default timeout on receiving from client
public const int MQTT_DEFAULT_TIMEOUT = 25000;
// max publish, subscribe and unsubscribe retry for QoS Level 1 or 2
public const int MQTT_ATTEMPTS_RETRY = 3;
// delay for retry publish, subscribe and unsubscribe for QoS Level 1 or 2
public const int MQTT_DELAY_RETRY = 10000;
// broker need to receive the first message (CONNECT)
// within a reasonable amount of time after TCP/IP connection
public const int MQTT_CONNECT_TIMEOUT = 25000;
///
/// Listening connection port
///
public int Port { get; internal set; }
///
/// Listening connection SSL port
///
public int SslPort { get; internal set; }
///
/// Timeout on client connection (before receiving CONNECT message)
///
public int TimeoutOnConnection { get; internal set; }
///
/// Timeout on receiving
///
public int TimeoutOnReceiving { get; internal set; }
///
/// Attempts on retry
///
public int AttemptsOnRetry { get; internal set; }
///
/// Delay on retry
///
public int DelayOnRetry { get; internal set; }
///
/// Singleton instance of settings
///
public static MqttSettings Instance
{
get
{
if (instance == null)
instance = new MqttSettings();
return instance;
}
}
// singleton instance
private static MqttSettings instance;
///
/// Constructor
///
private MqttSettings()
{
this.Port = MQTT_BROKER_DEFAULT_PORT;
this.SslPort = MQTT_BROKER_DEFAULT_SSL_PORT;
this.TimeoutOnReceiving = MQTT_DEFAULT_TIMEOUT;
this.AttemptsOnRetry = MQTT_ATTEMPTS_RETRY;
this.DelayOnRetry = MQTT_DELAY_RETRY;
this.TimeoutOnConnection = MQTT_CONNECT_TIMEOUT;
}
}
}