Guest User

Untitled

a guest
Jun 25th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. @IBAction func subscribeTopic(_ sender: Any) {
  2. let topic = mqttTopic.text
  3.  
  4. if !subscribeBool{
  5. subscribeBool = true
  6. mqtt?.subscribe(topic!)
  7. }
  8. else{
  9. subscribeBool = false
  10. mqtt?.unsubscribe(topic!)
  11. }
  12.  
  13. mqtt?.didSubscribeTopic = { mqtt , topic in
  14. //訂閱後要執行的程式碼
  15. }
  16.  
  17. mqtt?.didUnsubscribeTopic = { mqtt , topic in
  18. //解除訂閱後要執行的程式碼
  19. }
  20.  
  21. }
Add Comment
Please, Sign In to add comment