StompClientKit is a framework library of Stomp Client, over websoket.
Stomp
Starscream
. Targeted Users Developers who want to use Stomp as a wire protocol to handle webcoket frames.
. Supported Stomp Versions
1.0 up to 1.2
. Supported Swift and Xcode version
This library was developed in the environment of Xcode11, Swift5.2. Use it for other versions at your own discretion.
import StompClientKit
var stompclient = StompClient(endpoint: "ws://abc.example.com/anywebsocket/endpoint")
stompclient.messageHandler = self.handleMessage
stompclient.startConnect ( onConnected: {
client in
client.subscribe(to: "/awesome/topic")
})
func handleMessage(frame: Frame) {
DispatchQueue.main.async {
do {
let dto = try JSONDecoder().decode(ContentDto.self, from: frame.body.data)
self.content.message = dto.content
} catch {
// Deserialization error
print("Error occoured while decoding message body")
}
}
}
let jsonString = JSONEncoder().encode(object)
client.send(json: jsonString, to:"/app/sayhello", using:.utf8, conentType:"application/json")
let text = "hello!"
client.send(text: text, to:"/app/sayhello", using:.utf8, conentType:"text/plain")
client.send(json: stompMsgObj, to:"/app/sayhello", using:.utf8, conentType:"application/json")
// Or
client.send(text: stompMsgObj, to:"/app/sayhello", using:.utf8, conentType:"text/plain")
#Installation For now, StompClientKit supports only Swift Package Manager.
Add following dependency to your Swift Project.
Xcode -> File -> Swift Packages
-> Add Package Dependences
For Package developer: add following lines to your Package.swift file.
dependencies: [
.Package(url: "https://github.com/gridscaleinc/StompClientKit.git", majorVersion: x)
]
#License Licensed under the Apache v2 License.