@@ -72,8 +72,8 @@ public class StompClientLib: NSObject, SRWebSocketDelegate {
72
72
var sessionId : String ?
73
73
var delegate : StompClientLibDelegate ?
74
74
var connectionHeaders : [ String : String ] ?
75
+ public var connection : Bool = false
75
76
public var certificateCheckEnabled = true
76
-
77
77
private var urlRequest : NSURLRequest ?
78
78
79
79
public func sendJSONForDict( dict: AnyObject , toDestination destination: String ) {
@@ -98,6 +98,7 @@ public class StompClientLib: NSObject, SRWebSocketDelegate {
98
98
public func openSocketWithURLRequest( request: NSURLRequest , delegate: StompClientLibDelegate , connectionHeaders: [ String : String ] ? ) {
99
99
self . connectionHeaders = connectionHeaders
100
100
openSocketWithURLRequest ( request: request, delegate: delegate)
101
+ self . connection = true
101
102
}
102
103
103
104
private func openSocket( ) {
@@ -339,7 +340,12 @@ public class StompClientLib: NSObject, SRWebSocketDelegate {
339
340
sendFrame ( command: StompCommands . commandSend, header: headersToSend, body: message as AnyObject )
340
341
}
341
342
343
+ public func isConnected( ) -> Bool {
344
+ return connection
345
+ }
346
+
342
347
public func subscribe( destination: String ) {
348
+ connection = true
343
349
subscribeToDestination ( destination: destination, ackMode: . AutoMode)
344
350
}
345
351
@@ -366,6 +372,7 @@ public class StompClientLib: NSObject, SRWebSocketDelegate {
366
372
}
367
373
368
374
public func unsubscribe( destination: String ) {
375
+ connection = false
369
376
var headerToSend = [ String: String] ( )
370
377
headerToSend [ StompCommands . commandHeaderDestinationId] = destination
371
378
sendFrame ( command: StompCommands . commandUnsubscribe, header: headerToSend, body: nil )
@@ -403,6 +410,7 @@ public class StompClientLib: NSObject, SRWebSocketDelegate {
403
410
}
404
411
405
412
public func disconnect( ) {
413
+ connection = false
406
414
var headerToSend = [ String: String] ( )
407
415
headerToSend [ StompCommands . commandDisconnect] = String ( Int ( NSDate ( ) . timeIntervalSince1970) )
408
416
sendFrame ( command: StompCommands . commandDisconnect, header: headerToSend, body: nil )
0 commit comments