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
541 stars 135 forks source link

Get message without blocking #113

Closed nik736 closed 6 years ago

nik736 commented 6 years ago

I would like to .get a message in a specific topic but without blocking if there is no message. So should simply return the message if it is present (for example a retained message) and if not instead of blocking just return nothing.

How would I achieve this with ruby-mqtt?

Thanks

njh commented 6 years ago

I assume you solved your problem.

But for anyone else finding this issue, you can used queue_empty? to check if there are any messages available.