module MqttRails
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
Public Instance Methods
# File lib/mqtt-rails.rb, line 137 def check_topics(topics, filters) if topics.is_a?(String) && filters.is_a?(String) else Rails.logger.error("[MQTT RAILS][ERROR] Topics or Wildcards are not found as String.") raise ArgumentError end end
# File lib/mqtt-rails.rb, line 129 def is_end?(topic_part, filter_part) topic_part.nil? || filter_part.nil? end
# File lib/mqtt-rails.rb, line 133 def is_matching?(rc, topic_length, filter_length, index) rc || index == [topic_length, filter_length].max end
# File lib/mqtt-rails.rb, line 125 def is_wildcard?(filter_part) filter_part == '#' end
# File lib/mqtt-rails.rb, line 121 def keep_running?(filter_part, topic_part) filter_part == topic_part || filter_part == '+' end
# File lib/mqtt-rails.rb, line 100 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