paho-mqtt 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ module PahoMqtt
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'paho.mqtt/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "paho-mqtt"
8
+ spec.version = PahoMqtt::VERSION
9
+ spec.authors = ["Pierre Goudet"]
10
+ spec.email = ["p-goudet@ruby-dev.jp"]
11
+
12
+ spec.summary = %q{A simple mqtt client gem}
13
+ spec.description = %q{A simple mqtt client gem}
14
+ spec.homepage = "http://ruby-dev.jp"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|benchmark)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ end
@@ -0,0 +1,31 @@
1
+ require "./paho_client"
2
+ require "./packet_manager"
3
+ require "json"
4
+
5
+ cli = PahoRuby::Client.new
6
+ cli.ssl = true
7
+ cli.config_ssl_context("/Users/Pierre/certs/certificate.pem.crt", "/Users/Pierre/certs/private.pem.key", "/Users/Pierre/certs/root-CA.crt")
8
+
9
+ cli.connect('a15ipmbgzhr3uc.iot.ap-northeast-1.amazonaws.com', 8883)
10
+
11
+ cli.subscribe(["topic1", 1], ["topic2", 1])
12
+ sleep 2
13
+
14
+ #cli.on_message = lambda { |topic, payload, qos| puts ">>>>> This is a LAMBDA callback for message event <<<<<\nTopic: #{topic}\nPayload: #{payload}\nQoS: #{qos}" }
15
+
16
+ cli.add_topic_callback('topic1') do
17
+ puts "I am callback for topic 1"
18
+ end
19
+
20
+ cli.add_topic_callback('topic2') do
21
+ puts "I am callback for topic 2"
22
+ end
23
+
24
+ cli.publish("topic1", "Hi there! My name is PahoRuby.", false, 1)
25
+ cli.publish("topic2", "Hi there! My name is PahoRuby2.", false, 1)
26
+
27
+ #payload = JSON.generate({ :state => { :desired => { :aisatsu => "こんばは" }}})
28
+ #cli.publish("$aws/things/MyRasPi/shadow/update", payload, false, 1)
29
+ sleep 2
30
+
31
+ cli.disconnect
@@ -0,0 +1,64 @@
1
+ require "../lib/paho_client"
2
+ require "../lib/packet_manager"
3
+ require "pp"
4
+
5
+ cli = PahoRuby::Client.new
6
+ cli.ssl = true
7
+ cli.config_ssl_context("/Users/Pierre/certs/test/mykey.crt", "/Users/Pierre/certs/test/mykey.key")
8
+ cli.connect('test.mosquitto.org', 8883)
9
+
10
+ #########################################################
11
+ ### Callback settings
12
+
13
+ cli.on_message = lambda { |topic, payload, qos| puts ">>>>> This is a LAMBDA callback for message event <<<<<\nTopic: #{topic}\nPayload: #{payload}\nQoS: #{qos}" }
14
+
15
+ toto_toto = lambda { puts ">>>>> I am LAMBDA callback for the /toto/toto topic <<<<<" }
16
+ toto_tata = proc { puts ">>>>> I am PROC callback for the /toto/tata topic <<<<<" }
17
+
18
+
19
+ cli.add_topic_callback('/toto/tutu') do
20
+ puts ">>>>> I am BLOCK callback for the /toto/tutu topic <<<<<"
21
+ end
22
+ cli.add_topic_callback('/toto/tata', toto_tata)
23
+ cli.add_topic_callback('/toto/toto', toto_toto)
24
+
25
+ #########################################################
26
+
27
+ cli.subscribe(['/toto/toto', 0], ['/toto/tata', 1], ['/toto/tutu', 2], ["/toto", 0])
28
+
29
+ sleep 1
30
+
31
+ cli.publish("/toto/tutu", "It's me!", false, 2)
32
+ cli.publish("/toto/tutu", "It's you!", false, 1)
33
+ cli.publish("/toto/tutu", "It's them!", false, 0)
34
+
35
+ cli.publish("/toto/tata", "It's me!", false, 2)
36
+ cli.publish("/toto/tata", "It's you!", false, 1)
37
+ cli.publish("/toto/tata", "It's them!", false, 0)
38
+
39
+ cli.publish("/toto/toto", "It's me!", false, 2)
40
+ cli.publish("/toto/toto", "It's you!", false, 1)
41
+ cli.publish("/toto/toto", "It's them!", false, 0)
42
+
43
+ sleep 3
44
+
45
+ cli.on_message = nil
46
+ toto_tutu = lambda { puts ">>>>> Changing callback type to LAMBDA for the /toto/tutu topic <<<<<" }
47
+ cli.add_topic_callback('/toto/tutu', toto_tutu)
48
+ cli.add_topic_callback('/toto/tata') do
49
+ puts ">>>>> Changing callback type to BLOCK for the /toto/tata topic <<<<<"
50
+ end
51
+
52
+ cli.publish("/toto/tutu", "It's me!", false, 2)
53
+ cli.publish("/toto/tutu", "It's you!", false, 1)
54
+ cli.publish("/toto/tutu", "It's them!", false, 0)
55
+
56
+ cli.publish("/toto/tata", "It's me!", false, 2)
57
+ cli.publish("/toto/tata", "It's you!", false, 1)
58
+ cli.publish("/toto/tata", "It's them!", false, 0)
59
+
60
+ sleep 3
61
+ cli.unsubscribe('+/tutu', "+/+")
62
+ sleep 10
63
+
64
+ cli.disconnect
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paho-mqtt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pierre Goudet
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: A simple mqtt client gem
56
+ email:
57
+ - p-goudet@ruby-dev.jp
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/paho-mqtt.rb
73
+ - lib/paho.mqtt/packet_manager.rb
74
+ - lib/paho.mqtt/paho_client.rb
75
+ - lib/paho.mqtt/version.rb
76
+ - paho-mqtt.gemspec
77
+ - samples/test_aws.rb
78
+ - samples/test_init.rb
79
+ homepage: http://ruby-dev.jp
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.4.5.1
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: A simple mqtt client gem
103
+ test_files: []