Swift STOMP client for swift via WebSocketTask with Heart-beating
- iOS 15.0+
- macOS 12.0+
- tvOS 15.0+
- watchOS 8.0+
- Heart beat
- Auto Reconnect
let webSocket: WebSocketService = WebSocketManager(request: URLRequest(url: NetworkConstants.baseSTOMP))
let heartBeat: HeartBeatService = HeartBeatManager(clientHeartBeating: "2000,5000", clientSendingLeeway: 0.0)
let stompClient: SwiftStompClient = .init(webSocket: webSocket, heartBeat: heartBeat)
stompClient.stompDelegate = self
try await stompClient.openWebSocketConnection()
native webSocket implementation via URLSessionWebSocketTask
optinal service for receiving pong frame from server and sending ping frame to server, initialisation with the string clientHeartBeating: 2000,5000
where 2000
(in milliseconds) is the time to send a ping frame to the server 5000
is the time to wait for the ping frame to be received from the server, clientSendingLeeway
this is the time we set aside for sending a ping frame, for more information please visit Heart-beating
service that implements STOMP
connect webSocket
openWebSocketConnection()
disconnect webSocket
disconnectWebSocket(code: Int, reason: Data?)
reconnect webSocket
reconnectWebSocket(nanoseconds: UInt64)
send STOMP frames
sendFrame(frame: StompFrameProtocol)
func webSocketConnected()
is called when a webSocket connection is opened
func receiveStomp(
frame: SwiftStompClient,
type: FrameResponseKeys,
headers: [String : String],
body: String?
)
is called when any frame is received
func webSocketDisconnected(closeCode: Int, reason: Data?)
is called when the webSocket is closed
func handle(error: SwiftStompError)
is called when receive any errors
dependencies: [
.package(url: "https://github.com/mob-connection/SwiftStompClient.git", .upToNextMajor(from: "0.0.8"))
]
or (if needed)
.product(name: "SwiftStompClientDynamic", package: "SwiftStompClient")
pod 'SwiftStompClient'