Skip to content

Instantly share code, notes, and snippets.

@michaelklishin
Created June 27, 2014 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelklishin/dc3f8c44e081a26a2f3d to your computer and use it in GitHub Desktop.
Save michaelklishin/dc3f8c44e081a26a2f3d to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require "mqtt"
client = MQTT::Client.new('localhost', :ssl => :TLSv1)
client.ca_file = "/Users/antares/Tools/rabbitmq/tls/ca_certificate.pem"
client.cert_file = "/Users/antares/Tools/rabbitmq/tls/client_certificate.pem"
client.key_file = "/Users/antares/Tools/rabbitmq/tls/client_key.pem"
client.connect do
client.subscribe('test')
# Send a message
client.publish('test', "hello world")
# If you pass a block to the get method, then it will loop
topic, message = client.get
p [topic, message]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment