-
-
Save michaelklishin/dc3f8c44e081a26a2f3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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