Skip to content

Instantly share code, notes, and snippets.

@soramugi
Created December 30, 2014 08:23
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 soramugi/4966c23ffafeb48d44ef to your computer and use it in GitHub Desktop.
Save soramugi/4966c23ffafeb48d44ef to your computer and use it in GitHub Desktop.
mqttコネクションはるやつ
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