Module: Z4broker

Defined in:
lib/z4broker.rb,
lib/z4broker/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

ACK =
lambda {|a| puts "[z4broker][PUBACK] #{a}" }
MSG =
lambda {|k,v| puts "[z4broker][PUB] #{k}: #{v}" }
CLIENT =
PahoMqtt::Client.new
VERSION =
"0.1.1"
@@EV =
{}
@@ACK =
ACK

Class Method Summary collapse

Class Method Details

.on(k, &b) ⇒ Object



43
44
45
46
# File 'lib/z4broker.rb', line 43

def self.on k, &b
  @@EV[k] = b
  CLIENT.subscribe([k,2])
end

.send(k, v, &b) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/z4broker.rb', line 34

def self.send k,v, &b
  if block_given?
    @@ACK = b
  else
    @@ACK = ACK
  end
  CLIENT.publish(k, v, false, 1)
end