module PahoMqtt

Copyright © 2016-2018 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Copyright © 2016-2017 Pierre Goudet <p-goudet@ruby-dev.jp>

All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution.

The Eclipse Public License is available at

https://eclipse.org/org/documents/epl-v10.php.

and the Eclipse Distribution License is available at

https://eclipse.org/org/documents/edl-v10.php.

Contributors:

Pierre Goudet - initial committer

Constants

CLIENT_ATTR_DEFAULTS
CONNACK_ERROR_MESSAGE
DEFAULT_PORT
DEFAULT_SSL_PORT

Default connection setup

MAX_PACKET_ID
MAX_PUBLISH
MAX_QUEUE
MAX_SUBACK

MAX size of queue

MAX_UNSUBACK
MQTT_CS_CONNECTED
MQTT_CS_DISCONNECT
MQTT_CS_NEW

Connection states values

MQTT_ERR_FAIL
MQTT_ERR_SUCCESS

Error values

PACKET_TYPES
SELECT_TIMEOUT
VERSION

Attributes

logger[RW]

Public Instance Methods

check_topics(topics, filters) click to toggle source
# File lib/paho-mqtt.rb, line 155
def check_topics(topics, filters)
  if topics.is_a?(String) && filters.is_a?(String)
  else
    @logger.error("Topics or Wildcards are not found as String.") if logger?
    raise ArgumentError
  end
end
is_end?(topic_part, filter_part) click to toggle source
# File lib/paho-mqtt.rb, line 147
def is_end?(topic_part, filter_part)
  topic_part.nil? || filter_part.nil?
end
is_matching?(rc, topic_length, filter_length, index) click to toggle source
# File lib/paho-mqtt.rb, line 151
def is_matching?(rc, topic_length, filter_length, index)
  rc || index == [topic_length, filter_length].max
end
is_wildcard?(filter_part) click to toggle source
# File lib/paho-mqtt.rb, line 143
def is_wildcard?(filter_part)
  filter_part == '#'
end
keep_running?(filter_part, topic_part) click to toggle source
# File lib/paho-mqtt.rb, line 139
def keep_running?(filter_part, topic_part)
  filter_part == topic_part || filter_part == '+'
end
logger=(logger_path) click to toggle source
# File lib/paho-mqtt.rb, line 102
def logger=(logger_path)
  file           = File.open(logger_path, "a+")
  file.sync      = true
  log_file       = Logger.new(file)
  log_file.level = Logger::DEBUG
  @logger        = log_file
end
logger?() click to toggle source
# File lib/paho-mqtt.rb, line 114
def logger?
  @logger.is_a?(Logger)
end
match_filter(topics, filters) click to toggle source
# File lib/paho-mqtt.rb, line 118
def match_filter(topics, filters)
  check_topics(topics, filters)
  index = 0
  rc = false
  topic = topics.split('/')
  filter = filters.split('/')
  while index < [topic.length, filter.length].max do
    if is_end?(topic[index], filter[index])
      break
    elsif is_wildcard?(filter[index])
      rc = index == (filter.length - 1)
      break
    elsif keep_running?(filter[index], topic[index])
      index = index + 1
    else
      break
    end
  end
  is_matching?(rc, topic.length, filter.length, index)
end