Skip to content

Commit

Permalink
MQTT protocol, fully integrated now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aquaj committed Jan 17, 2017
1 parent e839556 commit bac7dd7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -166,7 +166,7 @@ gem 'mechanize'
gem 'rest-client', require: false
gem 'rubyntlm', '>= 0.3.2'
gem 'savon'
gem 'mqtt'
gem 'mqtt', git: 'https://github.com/aquaj/ruby-mqtt.git'

gem 'luhn'

Expand Down
9 changes: 7 additions & 2 deletions Gemfile.lock
@@ -1,3 +1,9 @@
GIT
remote: https://github.com/aquaj/ruby-mqtt.git
revision: e5819457bb0e2b625dda6ed280c2133368e828ac
specs:
mqtt (0.4.0)

GIT
remote: https://github.com/lcoq/ofx-parser.git
revision: 3c4cbb43d3df1be3f9493f45a82dabec02edf866
Expand Down Expand Up @@ -273,7 +279,6 @@ GEM
ruby-progressbar
momentjs-rails (2.17.1)
railties (>= 3.1)
mqtt (0.4.0)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
Expand Down Expand Up @@ -590,7 +595,7 @@ DEPENDENCIES
mechanize
minitest-reporters
momentjs-rails (>= 2.9.0)
mqtt
mqtt!
nokogiri (~> 1.6.0)
octopush-ruby
ofx-parser!
Expand Down
1 change: 1 addition & 0 deletions lib/action_integration/base.rb
Expand Up @@ -7,6 +7,7 @@ class Base

include_protocol ActionIntegration::Protocols::HTML
include_protocol ActionIntegration::Protocols::JSON
include_protocol ActionIntegration::Protocols::MQTT
include_protocol ActionIntegration::Protocols::Savon

def initialize(call)
Expand Down
28 changes: 15 additions & 13 deletions lib/action_integration/protocols/mqtt.rb
@@ -1,20 +1,22 @@
module ActionIntegration
# Handles the MQTT communication protocol
module MQTT
def connect(*args, **kwargs)
@mqtt_client = MQTT::Client.connect(*args, **kwargs)
end
module Protocols
# Handles the MQTT communication protocol
module MQTT
def connect(*args, **kwargs, &block)
@mqtt_client = ::MQTT::Client.connect(*args, **kwargs, &block)
end

def publish(topic, payload, retain = false)
@mqtt_client.publish(topic, payload, retain)
end
def publish(topic, payload, retain = false)
@mqtt_client.publish(topic, payload, retain)
end

def subscribe(*topics)
@mqtt_client.subscribe(*topics)
end
def subscribe(*topics)
@mqtt_client.subscribe(*topics)
end

def get(topic = nil, &block)
@mqtt_client.get(topic, &block)
def get(topic = nil, &block)
@mqtt_client.get(topic, &block)
end
end
end
end

0 comments on commit bac7dd7

Please sign in to comment.