Skip to content

Commit

Permalink
Update closure error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Adolfo Martinelli committed Apr 21, 2018
1 parent 3c75935 commit b3c2e14
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions SwiftMQTTExample/SwiftMQTTExample/MQTTViewController.swift
Expand Up @@ -55,11 +55,10 @@ class MQTTViewController: UIViewController, MQTTSessionDelegate {
appendStringToTextView("Trying to connect to \(host) on port \(port) for clientID \(clientID)")

mqttSession.connect { (error) in
switch error {
case .none:
if error == .none {
self.appendStringToTextView("Connected.")
self.subscribeToChannel()
default:
} else {
self.appendStringToTextView("Error occurred during connection:")
self.appendStringToTextView(error.localizedDescription)
}
Expand All @@ -69,10 +68,9 @@ class MQTTViewController: UIViewController, MQTTSessionDelegate {
func subscribeToChannel() {
let channel = "/#"
mqttSession.subscribe(to: channel, delivering: .atLeastOnce) { (error) in
switch error {
case .none:
if error == .none {
self.appendStringToTextView("Subscribed to \(channel)")
default:
} else {
self.appendStringToTextView("Error occurred during subscription:")
self.appendStringToTextView(error.localizedDescription)
}
Expand Down

0 comments on commit b3c2e14

Please sign in to comment.