From f9ddcb18c5a945ece95e19082898186673d9f718 Mon Sep 17 00:00:00 2001 From: erhannis Date: Thu, 27 Jun 2019 03:33:05 -0400 Subject: [PATCH 1/2] Added 'akaStringBody' parameter to stompClient didReceiveMessage... --- Example/StompClientLib.swift | 4 ++-- Example/StompClientLib/ViewController.swift | 3 ++- README.md | 3 ++- StompClientLib/Classes/StompClientLib.swift | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Example/StompClientLib.swift b/Example/StompClientLib.swift index 40d5c12..591787a 100755 --- a/Example/StompClientLib.swift +++ b/Example/StompClientLib.swift @@ -58,7 +58,7 @@ public enum StompAckMode { // Fundamental Protocols public protocol StompClientLibDelegate { - func stompClient(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: AnyObject?, withHeader header:[String:String]?, withDestination destination: String) + func stompClient(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: AnyObject?, akaStringBody stringBody: String?, withHeader header:[String:String]?, withDestination destination: String) func stompClientDidDisconnect(client: StompClientLib!) func stompClientDidConnect(client: StompClientLib!) @@ -298,7 +298,7 @@ public class StompClientLib: NSObject, SRWebSocketDelegate { // Response if let delegate = delegate { DispatchQueue.main.async(execute: { - delegate.stompClient(client: self, didReceiveMessageWithJSONBody: self.dictForJSONString(jsonStr: body), withHeader: headers, withDestination: self.destinationFromHeader(header: headers)) + delegate.stompClient(client: self, didReceiveMessageWithJSONBody: self.dictForJSONString(jsonStr: body), akaStringBody: body, withHeader: headers, withDestination: self.destinationFromHeader(header: headers)) }) } } else if command == StompCommands.responseFrameReceipt { // diff --git a/Example/StompClientLib/ViewController.swift b/Example/StompClientLib/ViewController.swift index 1e01d31..b59741c 100755 --- a/Example/StompClientLib/ViewController.swift +++ b/Example/StompClientLib/ViewController.swift @@ -49,9 +49,10 @@ class ViewController: UIViewController, StompClientLibDelegate { print("Socket is Disconnected") } - func stompClient(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: AnyObject?, withHeader header: [String : String]?, withDestination destination: String) { + func stompClient(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: AnyObject?, akaStringBody stringBody: String?, withHeader header: [String : String]?, withDestination destination: String) { print("DESTIONATION : \(destination)") print("JSON BODY : \(String(describing: jsonBody))") + print("STRING BODY : \(stringBody ?? "nil")") } func stompClientJSONBody(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: String?, withHeader header: [String : String]?, withDestination destination: String) { diff --git a/README.md b/README.md index 8b0ef8f..e1a899d 100755 --- a/README.md +++ b/README.md @@ -114,9 +114,10 @@ print("Socket is Disconnected") Your json message will be converted to JSON Body as AnyObject and you will receive your message in this function ```ruby -func stompClient(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: AnyObject?, withHeader header: [String : String]?, withDestination destination: String) { +func stompClient(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: AnyObject?, akaStringBody stringBody: String?, withHeader header: [String : String]?, withDestination destination: String) { print("Destination : \(destination)") print("JSON Body : \(String(describing: jsonBody))") +print("String Body : \(stringBody ?? "nil")") } ``` diff --git a/StompClientLib/Classes/StompClientLib.swift b/StompClientLib/Classes/StompClientLib.swift index a9bf6ca..d9548cf 100755 --- a/StompClientLib/Classes/StompClientLib.swift +++ b/StompClientLib/Classes/StompClientLib.swift @@ -58,7 +58,7 @@ public enum StompAckMode { // Fundamental Protocols public protocol StompClientLibDelegate { - func stompClient(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: AnyObject?, withHeader header:[String:String]?, withDestination destination: String) + func stompClient(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: AnyObject?, akaStringBody stringBody: String?, withHeader header:[String:String]?, withDestination destination: String) func stompClientDidDisconnect(client: StompClientLib!) func stompClientDidConnect(client: StompClientLib!) @@ -296,7 +296,7 @@ public class StompClientLib: NSObject, SRWebSocketDelegate { // Response if let delegate = delegate { DispatchQueue.main.async(execute: { - delegate.stompClient(client: self, didReceiveMessageWithJSONBody: self.dictForJSONString(jsonStr: body), withHeader: headers, withDestination: self.destinationFromHeader(header: headers)) + delegate.stompClient(client: self, didReceiveMessageWithJSONBody: self.dictForJSONString(jsonStr: body), akaStringBody: body, withHeader: headers, withDestination: self.destinationFromHeader(header: headers)) }) } } else if command == StompCommands.responseFrameReceipt { // From b1ba0295d16405c3d6f9118fdd2e131a65826686 Mon Sep 17 00:00:00 2001 From: Matthew Ewer Date: Tue, 16 Jul 2019 10:11:14 -0400 Subject: [PATCH 2/2] Fixed header parsing to allow values with : in them --- StompClientLib/Classes/StompClientLib.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StompClientLib/Classes/StompClientLib.swift b/StompClientLib/Classes/StompClientLib.swift index d9548cf..fe2b4a5 100755 --- a/StompClientLib/Classes/StompClientLib.swift +++ b/StompClientLib/Classes/StompClientLib.swift @@ -163,7 +163,7 @@ public class StompClientLib: NSObject, SRWebSocketDelegate { } else { let parts = line.components(separatedBy: ":") if let key = parts.first { - headers[key] = parts.last + headers[key] = parts.dropFirst().joined(separator: ":") } } }