SocketRocket library subscribe topic ios

383 Views Asked by At

I'm using SocketRocket library: SocketRocket Github for mqtt over websockets. I successfully connected server.

let socket = SRWebSocket(url: mUrl, protocols: ["mqtt"], allowsUntrustedSSLCertificates: true)
socket.delegate = self
socket.open()

I detect is websocket ready as below:

func webSocketDidOpen(_ webSocket: SRWebSocket!) {
   print("SRWebSocket webSocketDidOpen")
}

But I don't know how to subscribe topic with SocketRocket library. I opened new issue in github for this: How to subscribe topic in ios ? but I can't get a response. Thank you for your help.

1

There are 1 best solutions below

0
On

SocketRocket appears to just be a WebSocket library, if you want to run MQTT over Websockets you would need to implement your own MQTT library that can read and write the raw protocol over the connection SocketRocket has created.

A quick Google turns up several libraries which seams to have already done this for you e.g.

https://github.com/hapim/IOS-MQTT-Websocket-Client