Method: MQTT::Client.connect

Defined in:
lib/mqtt/client.rb

.connect(*args, &block) ⇒ Object

Create and connect a new MQTT Client

Accepts the same arguments as creating a new client. If a block is given, then it will be executed before disconnecting again.

Example:

MQTT::Client.connect('myserver.example.com') do |client|
  # do stuff here
end


91
92
93
94
95
# File 'lib/mqtt/client.rb', line 91

def self.connect(*args, &block)
  client = MQTT::Client.new(*args)
  client.connect(&block)
  client
end