Skip to content

Commit f5aca87

Browse files
authored
Deprecate maxRetryAttempts configuration parameter (#99)
1 parent 55da431 commit f5aca87

File tree

2 files changed

+70
-6
lines changed

2 files changed

+70
-6
lines changed

Sources/MQTTNIO/MQTTClient.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ public final class MQTTClient {
8585
/// - Parameters:
8686
/// - host: host name
8787
/// - port: port to connect on
88+
/// - identifier: Client identifier. This must be unique
8889
/// - eventLoopGroupProvider: EventLoopGroup to run on
90+
/// - logger: Logger client should use
8991
/// - configuration: Configuration of client
90-
/// - publishCallback: called whenever there is a publish event
9192
public init(
9293
host: String,
9394
port: Int? = nil,

Sources/MQTTNIO/MQTTConfiguration.swift

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,28 @@ extension MQTTClient {
4040
/// Configuration for MQTTClient
4141
public struct Configuration {
4242
/// Initialize MQTTClient configuration struct
43+
/// - Parameters:
44+
/// - version: Version of MQTT server client is connecting to
45+
/// - disablePing: Disable the automatic sending of pingreq messages
46+
/// - keepAliveInterval: MQTT keep alive period.
47+
/// - pingInterval: Override calculated interval between each pingreq message
48+
/// - connectTimeout: Timeout for connecting to server
49+
/// - timeout: Timeout for server ACK responses
50+
/// - userName: MQTT user name
51+
/// - password: MQTT password
52+
/// - useSSL: Use encrypted connection to server
53+
/// - useWebSockets: Use a websocket connection to server
54+
/// - tlsConfiguration: TLS configuration, for SSL connection
55+
/// - sniServerName: Server name used by TLS. This will default to host name if not set
56+
/// - webSocketURLPath: URL Path for web socket. Defaults to "/mqtt"
57+
/// - webSocketMaxFrameSize: Maximum frame size for a web socket connection
4358
public init(
4459
version: Version = .v3_1_1,
4560
disablePing: Bool = false,
4661
keepAliveInterval: TimeAmount = .seconds(90),
4762
pingInterval: TimeAmount? = nil,
4863
connectTimeout: TimeAmount = .seconds(10),
4964
timeout: TimeAmount? = nil,
50-
maxRetryAttempts: Int = 4,
5165
userName: String? = nil,
5266
password: String? = nil,
5367
useSSL: Bool = false,
@@ -63,7 +77,58 @@ extension MQTTClient {
6377
self.pingInterval = pingInterval
6478
self.connectTimeout = connectTimeout
6579
self.timeout = timeout
66-
self.maxRetryAttempts = maxRetryAttempts
80+
self.userName = userName
81+
self.password = password
82+
self.useSSL = useSSL
83+
self.useWebSockets = useWebSockets
84+
self.tlsConfiguration = tlsConfiguration
85+
self.sniServerName = sniServerName
86+
self.webSocketURLPath = webSocketURLPath
87+
self.webSocketMaxFrameSize = webSocketMaxFrameSize
88+
}
89+
90+
/// Initialize MQTTClient configuration struct
91+
/// - Parameters:
92+
/// - version: Version of MQTT server client is connecting to
93+
/// - disablePing: Disable the automatic sending of pingreq messages
94+
/// - keepAliveInterval: MQTT keep alive period.
95+
/// - pingInterval: Override calculated interval between each pingreq message
96+
/// - connectTimeout: Timeout for connecting to server
97+
/// - timeout: Timeout for server ACK responses
98+
/// - maxRetryAttempts: Max number of times to send a message. This is deprecated
99+
/// - userName: MQTT user name
100+
/// - password: MQTT password
101+
/// - useSSL: Use encrypted connection to server
102+
/// - useWebSockets: Use a websocket connection to server
103+
/// - tlsConfiguration: TLS configuration, for SSL connection
104+
/// - sniServerName: Server name used by TLS. This will default to host name if not set
105+
/// - webSocketURLPath: URL Path for web socket. Defaults to "/mqtt"
106+
/// - webSocketMaxFrameSize: Maximum frame size for a web socket connection
107+
///
108+
@available(*, deprecated, message: "maxRetryAttempts is no longer used")
109+
public init(
110+
version: Version = .v3_1_1,
111+
disablePing: Bool = false,
112+
keepAliveInterval: TimeAmount = .seconds(90),
113+
pingInterval: TimeAmount? = nil,
114+
connectTimeout: TimeAmount = .seconds(10),
115+
timeout: TimeAmount? = nil,
116+
maxRetryAttempts: Int,
117+
userName: String? = nil,
118+
password: String? = nil,
119+
useSSL: Bool = false,
120+
useWebSockets: Bool = false,
121+
tlsConfiguration: TLSConfigurationType? = nil,
122+
sniServerName: String? = nil,
123+
webSocketURLPath: String? = nil,
124+
webSocketMaxFrameSize: Int = 1 << 14
125+
) {
126+
self.version = version
127+
self.disablePing = disablePing
128+
self.keepAliveInterval = keepAliveInterval
129+
self.pingInterval = pingInterval
130+
self.connectTimeout = connectTimeout
131+
self.timeout = timeout
67132
self.userName = userName
68133
self.password = password
69134
self.useSSL = useSSL
@@ -76,7 +141,7 @@ extension MQTTClient {
76141

77142
/// Version of MQTT server client is connecting to
78143
public let version: Version
79-
/// disable the sending of pingreq messages
144+
/// disable the automatic sending of pingreq messages
80145
public let disablePing: Bool
81146
/// MQTT keep alive period.
82147
public let keepAliveInterval: TimeAmount
@@ -86,8 +151,6 @@ extension MQTTClient {
86151
public let connectTimeout: TimeAmount
87152
/// timeout for server response
88153
public let timeout: TimeAmount?
89-
/// max number of times to send a message
90-
public let maxRetryAttempts: Int
91154
/// MQTT user name.
92155
public let userName: String?
93156
/// MQTT password.

0 commit comments

Comments
 (0)