Skip to content

Commit 2e0fa06

Browse files
committed
[FIX] added connectTo: version for backward compatibility
1 parent f26c7d3 commit 2e0fa06

File tree

4 files changed

+94
-19
lines changed

4 files changed

+94
-19
lines changed

Diff for: MQTTClient/MQTTClient/MQTTSessionManager.h

+55-16
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,61 @@ typedef NS_ENUM(int, MQTTSessionManagerState) {
235235

236236

237237
/** Connects to the MQTT broker and stores the parameters for subsequent reconnects
238-
* @param host specifies the hostname or ip address to connect to. Defaults to @"localhost".
239-
* @param port specifies the port to connect to
240-
* @param tls specifies whether to use SSL or not
241-
* @param keepalive The Keep Alive is a time interval measured in seconds. The MQTTClient ensures that the interval between Control Packets being sent does not exceed the Keep Alive value. In the absence of sending any other Control Packets, the Client sends a PINGREQ Packet.
242-
* @param clean specifies if the server should discard previous session information.
243-
* @param auth specifies the user and pass parameters should be used for authenthication
244-
* @param user an NSString object containing the user's name (or ID) for authentication. May be nil.
245-
* @param pass an NSString object containing the user's password. If userName is nil, password must be nil as well.
246-
* @param will indicates whether a will shall be sent
247-
* @param willTopic the Will Topic is a string, may be nil
248-
* @param willMsg the Will Message, might be zero length or nil
249-
* @param willQos specifies the QoS level to be used when publishing the Will Message.
250-
* @param willRetainFlag indicates if the server should publish the Will Messages with retainFlag.
251-
* @param clientId The Client Identifier identifies the Client to the Server. If nil, a random clientId is generated.
252-
* @param securityPolicy A custom SSL security policy or nil.
253-
* @param certificates An NSArray of the pinned certificates to use or nil.
238+
* @param host see connectTo description
239+
* @param port see connectTo description
240+
* @param tls see connectTo description
241+
* @param keepalive see connectTo description
242+
* @param clean see connectTo description
243+
* @param auth see connectTo description
244+
* @param user see connectTo description
245+
* @param pass see connectTo description
246+
* @param will see connectTo description
247+
* @param willTopic see connectTo description
248+
* @param willMsg see connectTo description
249+
* @param willQos see connectTo description
250+
* @param willRetainFlag see connectTo description
251+
* @param clientId see connectTo description
252+
* @param securityPolicy see connectTo description
253+
* @param certificates An see connectTo description
254+
* @param protocolLevel see connectTo description
255+
*/
256+
257+
- (void)connectTo:(NSString *)host
258+
port:(NSInteger)port
259+
tls:(BOOL)tls
260+
keepalive:(NSInteger)keepalive
261+
clean:(BOOL)clean
262+
auth:(BOOL)auth
263+
user:(NSString *)user
264+
pass:(NSString *)pass
265+
will:(BOOL)will
266+
willTopic:(NSString *)willTopic
267+
willMsg:(NSData *)willMsg
268+
willQos:(MQTTQosLevel)willQos
269+
willRetainFlag:(BOOL)willRetainFlag
270+
withClientId:(NSString *)clientId
271+
securityPolicy:(MQTTSSLSecurityPolicy *)securityPolicy
272+
certificates:(NSArray *)certificates
273+
protocolLevel:(MQTTProtocolVersion)protocolLevel;
274+
275+
276+
/** Connects to the MQTT broker and stores the parameters for subsequent reconnects
277+
* @param host see connectTo description
278+
* @param port see connectTo description
279+
* @param tls see connectTo description
280+
* @param keepalive see connectTo description
281+
* @param clean see connectTo description
282+
* @param auth see connectTo description
283+
* @param user see connectTo description
284+
* @param pass see connectTo description
285+
* @param will see connectTo description
286+
* @param willTopic see connectTo description
287+
* @param willMsg see connectTo description
288+
* @param willQos see connectTo description
289+
* @param willRetainFlag see connectTo description
290+
* @param clientId see connectTo description
291+
* @param securityPolicy see connectTo description
292+
* @param certificates An see connectTo description
254293
*/
255294

256295
- (void)connectTo:(NSString *)host

Diff for: MQTTClient/MQTTClient/MQTTSessionManager.m

+37
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,43 @@ - (void)connectTo:(NSString *)host
192192
certificates:nil];
193193
}
194194

195+
- (void)connectTo:(NSString *)host
196+
port:(NSInteger)port
197+
tls:(BOOL)tls
198+
keepalive:(NSInteger)keepalive
199+
clean:(BOOL)clean
200+
auth:(BOOL)auth
201+
user:(NSString *)user
202+
pass:(NSString *)pass
203+
will:(BOOL)will
204+
willTopic:(NSString *)willTopic
205+
willMsg:(NSData *)willMsg
206+
willQos:(MQTTQosLevel)willQos
207+
willRetainFlag:(BOOL)willRetainFlag
208+
withClientId:(NSString *)clientId
209+
securityPolicy:(MQTTSSLSecurityPolicy *)securityPolicy
210+
certificates:(NSArray *)certificates
211+
protocolLevel:(MQTTProtocolVersion)protocolLevel {
212+
[self connectTo:host
213+
port:port
214+
tls:tls
215+
keepalive:keepalive
216+
clean:clean
217+
auth:auth
218+
user:user
219+
pass:pass
220+
will:will
221+
willTopic:willTopic
222+
willMsg:willMsg
223+
willQos:willQos
224+
willRetainFlag:willRetainFlag
225+
withClientId:clientId
226+
securityPolicy:securityPolicy
227+
certificates:certificates
228+
protocolLevel:protocolLevel
229+
runLoop:[NSRunLoop currentRunLoop]];
230+
}
231+
195232
- (void)connectTo:(NSString *)host
196233
port:(NSInteger)port
197234
tls:(BOOL)tls

Diff for: MQTTClient/MQTTClientTests/MQTTTestMultiThreading.m

-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ - (void)start
5656
self.event = -1;
5757
[self.session connect];
5858
DDLogVerbose(@"%@ connecting", self.session.clientId);
59-
60-
6159
}
6260

6361
- (void)sub

Diff for: MQTTClient/MQTTClientTests/MQTTTestSessionManager.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ - (void)connectWithParameters:(NSDictionary *)parameters clean:(BOOL)clean {
3838
withClientId:nil
3939
securityPolicy:[MQTTTestHelpers securityPolicy:parameters]
4040
certificates:[MQTTTestHelpers clientCerts:parameters]
41-
protocolLevel:[parameters[@"protocollevel"] intValue]];
41+
protocolLevel:[parameters[@"protocollevel"] intValue]
42+
runLoop:[NSRunLoop currentRunLoop]];
4243
}
4344

4445
@end

0 commit comments

Comments
 (0)