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
543 stars 136 forks source link

Improve documentation for client.get (mention the fact it loops forever if passed a block) #46

Closed CloCkWeRX closed 10 years ago

CloCkWeRX commented 10 years ago

Doing this hangs:

      mqtt_client.connect do |c|

        c.get("/#") do |topic,message|     
         # Oh no, hangs forever

        end
        c.disconnect
      end

but doing this works for exactly one message:

      mqtt_client.connect do |c|

        topic, message =  c.get("/#")

        c.disconnect
     end

This is very confusing when writing specs

CloCkWeRX commented 10 years ago

Nevermind; the docs are clear enough.

I'm just struggling at the moment between accidentally causing it to loop forever in test and needing it to in real life.

njh commented 10 years ago

Implementing that could get complex.

I have just been using the fake server as a test harness in the rspec tests.

Are you using it for something else?

CloCkWeRX commented 10 years ago

https://github.com/cantino/huginn/pull/368 - I ended up needing a fake server, so pretty much used the one in the gem. See the nastyness with the timeout behaviour :p