Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String body parameter and ':'-in-header-value fix #56

Merged
merged 2 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Example/StompClientLib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down Expand Up @@ -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 { //
Expand Down
3 changes: 2 additions & 1 deletion Example/StompClientLib/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")")
}
```

Expand Down
6 changes: 3 additions & 3 deletions StompClientLib/Classes/StompClientLib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down Expand Up @@ -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: ":")
}
}
}
Expand Down Expand Up @@ -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 { //
Expand Down