From eca3806f0e75fe85eda6d1fcaf093f4878846bcd Mon Sep 17 00:00:00 2001 From: WrathChaos Date: Mon, 10 Jul 2017 18:49:25 +0300 Subject: [PATCH 1/2] Added isConnected function --- StompClientLib/Classes/StompClientLib.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/StompClientLib/Classes/StompClientLib.swift b/StompClientLib/Classes/StompClientLib.swift index bd0c5e5..387893e 100644 --- a/StompClientLib/Classes/StompClientLib.swift +++ b/StompClientLib/Classes/StompClientLib.swift @@ -72,8 +72,8 @@ public class StompClientLib: NSObject, SRWebSocketDelegate { var sessionId: String? var delegate: StompClientLibDelegate? var connectionHeaders: [String: String]? + public var connection: Bool = false public var certificateCheckEnabled = true - private var urlRequest: NSURLRequest? public func sendJSONForDict(dict: AnyObject, toDestination destination: String) { @@ -98,6 +98,7 @@ public class StompClientLib: NSObject, SRWebSocketDelegate { public func openSocketWithURLRequest(request: NSURLRequest, delegate: StompClientLibDelegate, connectionHeaders: [String: String]?) { self.connectionHeaders = connectionHeaders openSocketWithURLRequest(request: request, delegate: delegate) + self.connection = true } private func openSocket() { @@ -339,7 +340,12 @@ public class StompClientLib: NSObject, SRWebSocketDelegate { sendFrame(command: StompCommands.commandSend, header: headersToSend, body: message as AnyObject) } + public func isConnected() -> Bool{ + return connection + } + public func subscribe(destination: String) { + connection = true subscribeToDestination(destination: destination, ackMode: .AutoMode) } @@ -366,6 +372,7 @@ public class StompClientLib: NSObject, SRWebSocketDelegate { } public func unsubscribe(destination: String) { + connection = false var headerToSend = [String: String]() headerToSend[StompCommands.commandHeaderDestinationId] = destination sendFrame(command: StompCommands.commandUnsubscribe, header: headerToSend, body: nil) @@ -403,6 +410,7 @@ public class StompClientLib: NSObject, SRWebSocketDelegate { } public func disconnect() { + connection = false var headerToSend = [String: String]() headerToSend[StompCommands.commandDisconnect] = String(Int(NSDate().timeIntervalSince1970)) sendFrame(command: StompCommands.commandDisconnect, header: headerToSend, body: nil) From 05d59d29b72f4314177bf370f5c19537254de89f Mon Sep 17 00:00:00 2001 From: WrathChaos Date: Mon, 10 Jul 2017 18:50:14 +0300 Subject: [PATCH 2/2] Added isConnected function --- StompClientLib.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StompClientLib.podspec b/StompClientLib.podspec index a2f7def..82c97f7 100644 --- a/StompClientLib.podspec +++ b/StompClientLib.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'StompClientLib' - s.version = '0.1.4' + s.version = '0.1.5' s.summary = 'Simple STOMP Client library, Swift 3 compatible' # This description is used to generate tags and improve search results.