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..fe2b4a5 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!) @@ -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: ":") } } } @@ -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 { //