njh / ruby-mqtt

Pure Ruby gem that implements the MQTT protocol, a lightweight protocol for publish/subscribe messaging.
http://www.rubydoc.info/gems/mqtt
MIT License
538 stars 135 forks source link

background client #131

Closed abmahmoodi closed 3 years ago

abmahmoodi commented 3 years ago

How to run client subscription in background like a thread? I have this client subscriber:

client = MQTT::Client.connect('mqtt://USER:PASSWORD@IP') client.subscribe('test2')

client.get do |topic, message| p "#{topic}: #{message}" end

I want to run this code in Rails in a job by SuckerPunch

thanks