Skip to content

Commit 79f9194

Browse files
authored
Update README.md
1 parent f227fc2 commit 79f9194

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ Create a client with connection details and a closure to be called whenever a PU
1010
let client = MQTTClient(
1111
host: "mqtt.eclipse.org",
1212
eventLoopGroupProvider: .createNew
13-
) { result in
13+
)
14+
```
15+
16+
Subscribe to a topic and add a publish listener to report publish messages from the server.
17+
```swift
18+
let subscription = MQTTSubscribeInfo(
19+
qos: .atLeastOnce,
20+
topicFilter: "my-topics"
21+
)
22+
try client.subscribe(infos: [subscription]).wait()
23+
client.addPublishListener("My Listener") { result in
1424
switch result {
1525
case .success(let publish):
1626
var buffer = publish.payload
@@ -22,15 +32,6 @@ let client = MQTTClient(
2232
}
2333
```
2434

25-
Subscribe to a topic
26-
```swift
27-
let subscription = MQTTSubscribeInfo(
28-
qos: .atLeastOnce,
29-
topicFilter: "my-topics"
30-
)
31-
try client.subscribe(infos: [subscription]).wait()
32-
```
33-
3435
Publish to a topic.
3536
```swift
3637
let publish = MQTTPublishInfo(
@@ -44,4 +45,4 @@ try client.publish(info: publish).wait()
4445
```
4546
## WebSockets and SSL
4647

47-
There is support for WebSockets and SSL connections. You can enable these through the `Configuration` provided at initialization. I have only been able to verify these work with a small number of servers, so am not sure if the implementation of these is complete.
48+
There is support for WebSockets and TLS connections. You can enable these through the `Configuration` provided at initialization. For TLS connections set`Configuration.useSSL` to `true` and provide your SSL certificates via the `Configuration.tlsConfiguration` struct. For WebSockets set `Configuration.useWebSockets` to `true` and set the URL path in `Configuration.webSocketsURLPath`.

0 commit comments

Comments
 (0)