Created
December 30, 2014 08:23
-
-
Save soramugi/4966c23ffafeb48d44ef to your computer and use it in GitHub Desktop.
mqttコネクションはるやつ
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
require 'mqtt' | |
require 'uri' | |
uri = URI.parse(ENV['ACCESS_POINT']) | |
client = MQTT::Client.connect( | |
remote_host: uri.host, | |
remote_port: uri.port, | |
username: ENV['USER'], | |
password: ENV['PASS'], | |
) | |
#topic = ENV['TOPIC'].gsub('#', 'huge') | |
#client.publish(topic, 'message') | |
client.get(ENV['TOPIC']) do |topic,message| | |
p "topic:[#{topic}] message:[#{message}]" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment