nutella_framework 0.4.5 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +14 -15
  3. data/VERSION +1 -1
  4. data/framework_components/beacon-cloud-bot/README.md +27 -0
  5. data/framework_components/beacon-cloud-bot/beacon_cloud_bot.rb +154 -0
  6. data/framework_components/beacon-cloud-bot/nutella.json +6 -0
  7. data/framework_components/beacon-cloud-bot/startup +4 -0
  8. data/framework_components/beacon-cloud-interface/LICENSE +21 -0
  9. data/framework_components/beacon-cloud-interface/Readme.md +0 -0
  10. data/framework_components/beacon-cloud-interface/bower.json +29 -0
  11. data/framework_components/beacon-cloud-interface/bower_components/bower-mqttws/.bower.json +23 -0
  12. data/framework_components/beacon-cloud-interface/bower_components/bower-mqttws/bower.json +14 -0
  13. data/framework_components/beacon-cloud-interface/bower_components/bower-mqttws/mqttws31.js +2081 -0
  14. data/framework_components/beacon-cloud-interface/bower_components/bower-mqttws/readme.md +4 -0
  15. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/.bower.json +37 -0
  16. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/LICENSE +21 -0
  17. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/README.md +15 -0
  18. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/bower.json +28 -0
  19. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/browser/mqtt_client_hello_world.html +23 -0
  20. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/browser/nutella_hello_world.html +52 -0
  21. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/node/mqtt_client_hello_world.js +14 -0
  22. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/node/nutella_hello_world.js +38 -0
  23. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/nutella_lib.js +789 -0
  24. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/package.json +30 -0
  25. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/simple-js-mqtt-client.js +428 -0
  26. data/framework_components/beacon-cloud-interface/css/animation.css +17 -0
  27. data/framework_components/beacon-cloud-interface/css/cursor.css +16 -0
  28. data/framework_components/beacon-cloud-interface/css/page_layout.css +73 -0
  29. data/framework_components/beacon-cloud-interface/index.html +157 -0
  30. data/framework_components/beacon-cloud-interface/js/lib/nutella_lib.js +4039 -0
  31. data/framework_components/beacon-cloud-interface/js/react/beacon-add.js +102 -0
  32. data/framework_components/beacon-cloud-interface/js/react/beacon-table.js +73 -0
  33. data/framework_components/beacon-cloud-interface/js/react/beacon.js +97 -0
  34. data/framework_components/beacon-cloud-interface/nutella.json +6 -0
  35. data/framework_components/example_framework_web_interface/index.html +11 -2
  36. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/.npmignore +10 -0
  37. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/.travis.yml +5 -0
  38. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/LICENSE +21 -0
  39. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/README.md +27 -0
  40. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/dist/nutella_lib.js +4039 -0
  41. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/dist/nutella_lib.js.map +1 -0
  42. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/examples/browser_hello_world.html +67 -0
  43. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/examples/node_hello_world.js +51 -0
  44. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/gulpfile.js +31 -0
  45. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/package.json +41 -0
  46. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_core.js +19 -0
  47. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_core_browser.js +17 -0
  48. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_log.js +50 -0
  49. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_net.js +279 -0
  50. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_persist.js +20 -0
  51. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/fr_core_browser.js +17 -0
  52. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/fr_log.js +50 -0
  53. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/fr_net.js +499 -0
  54. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_i.js +74 -0
  55. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_i_browser.js +130 -0
  56. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_lib.js +91 -0
  57. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_lib_browser.js +90 -0
  58. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/run_log.js +51 -0
  59. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/run_net.js +84 -0
  60. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/run_persist.js +20 -0
  61. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/util/net.js +327 -0
  62. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/test/nutella.test.js +16 -0
  63. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/test/runner.html +22 -0
  64. data/framework_components/example_framework_web_interface/package.json +15 -0
  65. data/framework_components/{order.json.example → order.json} +0 -0
  66. data/framework_components/runs_list_bot/{app_runs_list_bot.rb → runs_list_bot.rb} +9 -3
  67. data/framework_components/runs_list_bot/startup +1 -1
  68. data/lib/commands/meta/run_command.rb +21 -36
  69. data/lib/commands/start.rb +9 -199
  70. data/lib/commands/util/components_list.rb +68 -0
  71. data/lib/commands/util/components_starter.rb +169 -0
  72. data/nutella_framework.gemspec +109 -47
  73. data/nutella_lib/framework_net.rb +17 -13
  74. metadata +84 -106
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: nutella_framework 0.4.5 ruby lib
5
+ # stub: nutella_framework 0.4.8 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "nutella_framework"
9
- s.version = "0.4.5"
9
+ s.version = "0.4.8"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Alessandro Gnoli"]
14
- s.date = "2015-03-26"
14
+ s.date = "2015-04-08"
15
15
  s.description = "utella is a framework to create and run RoomApps"
16
16
  s.email = "tebemis@gmail.com"
17
17
  s.executables = ["nutella"]
@@ -32,7 +32,67 @@ Gem::Specification.new do |s|
32
32
  "data/startup",
33
33
  "example_framework_components/example_framework_bot/example_framework_bot.rb",
34
34
  "example_framework_components/example_framework_bot/startup",
35
+ "framework_components/beacon-cloud-bot/README.md",
36
+ "framework_components/beacon-cloud-bot/beacon_cloud_bot.rb",
37
+ "framework_components/beacon-cloud-bot/nutella.json",
38
+ "framework_components/beacon-cloud-bot/startup",
39
+ "framework_components/beacon-cloud-interface/LICENSE",
40
+ "framework_components/beacon-cloud-interface/Readme.md",
41
+ "framework_components/beacon-cloud-interface/bower.json",
42
+ "framework_components/beacon-cloud-interface/bower_components/bower-mqttws/.bower.json",
43
+ "framework_components/beacon-cloud-interface/bower_components/bower-mqttws/bower.json",
44
+ "framework_components/beacon-cloud-interface/bower_components/bower-mqttws/mqttws31.js",
45
+ "framework_components/beacon-cloud-interface/bower_components/bower-mqttws/readme.md",
46
+ "framework_components/beacon-cloud-interface/bower_components/nutella_lib/.bower.json",
47
+ "framework_components/beacon-cloud-interface/bower_components/nutella_lib/LICENSE",
48
+ "framework_components/beacon-cloud-interface/bower_components/nutella_lib/README.md",
49
+ "framework_components/beacon-cloud-interface/bower_components/nutella_lib/bower.json",
50
+ "framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/browser/mqtt_client_hello_world.html",
51
+ "framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/browser/nutella_hello_world.html",
52
+ "framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/node/mqtt_client_hello_world.js",
53
+ "framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/node/nutella_hello_world.js",
54
+ "framework_components/beacon-cloud-interface/bower_components/nutella_lib/nutella_lib.js",
55
+ "framework_components/beacon-cloud-interface/bower_components/nutella_lib/package.json",
56
+ "framework_components/beacon-cloud-interface/bower_components/nutella_lib/simple-js-mqtt-client.js",
57
+ "framework_components/beacon-cloud-interface/css/animation.css",
58
+ "framework_components/beacon-cloud-interface/css/cursor.css",
59
+ "framework_components/beacon-cloud-interface/css/page_layout.css",
60
+ "framework_components/beacon-cloud-interface/index.html",
61
+ "framework_components/beacon-cloud-interface/js/lib/nutella_lib.js",
62
+ "framework_components/beacon-cloud-interface/js/react/beacon-add.js",
63
+ "framework_components/beacon-cloud-interface/js/react/beacon-table.js",
64
+ "framework_components/beacon-cloud-interface/js/react/beacon.js",
65
+ "framework_components/beacon-cloud-interface/nutella.json",
35
66
  "framework_components/example_framework_web_interface/index.html",
67
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/.npmignore",
68
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/.travis.yml",
69
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/LICENSE",
70
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/README.md",
71
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/dist/nutella_lib.js",
72
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/dist/nutella_lib.js.map",
73
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/examples/browser_hello_world.html",
74
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/examples/node_hello_world.js",
75
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/gulpfile.js",
76
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/package.json",
77
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_core.js",
78
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_core_browser.js",
79
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_log.js",
80
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_net.js",
81
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_persist.js",
82
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/fr_core_browser.js",
83
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/fr_log.js",
84
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/fr_net.js",
85
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_i.js",
86
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_i_browser.js",
87
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_lib.js",
88
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_lib_browser.js",
89
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/run_log.js",
90
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/run_net.js",
91
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/run_persist.js",
92
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/src/util/net.js",
93
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/test/nutella.test.js",
94
+ "framework_components/example_framework_web_interface/node_modules/nutella_lib/test/runner.html",
95
+ "framework_components/example_framework_web_interface/package.json",
36
96
  "framework_components/logging_bot/logging_bot.rb",
37
97
  "framework_components/logging_bot/startup",
38
98
  "framework_components/logging_bot/utils.rb",
@@ -41,8 +101,8 @@ Gem::Specification.new do |s|
41
101
  "framework_components/main_interface/startup",
42
102
  "framework_components/main_interface/views/index.erb",
43
103
  "framework_components/main_interface/views/not_found_404.erb",
44
- "framework_components/order.json.example",
45
- "framework_components/runs_list_bot/app_runs_list_bot.rb",
104
+ "framework_components/order.json",
105
+ "framework_components/runs_list_bot/runs_list_bot.rb",
46
106
  "framework_components/runs_list_bot/startup",
47
107
  "lib/commands/broker.rb",
48
108
  "lib/commands/checkup.rb",
@@ -58,6 +118,8 @@ Gem::Specification.new do |s|
58
118
  "lib/commands/start.rb",
59
119
  "lib/commands/stop.rb",
60
120
  "lib/commands/template.rb",
121
+ "lib/commands/util/components_list.rb",
122
+ "lib/commands/util/components_starter.rb",
61
123
  "lib/config/config.rb",
62
124
  "lib/config/current_app_utils.rb",
63
125
  "lib/config/persisted_hash.rb",
@@ -92,51 +154,51 @@ Gem::Specification.new do |s|
92
154
  s.specification_version = 4
93
155
 
94
156
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
95
- s.add_runtime_dependency(%q<semantic>, [">= 1.3", "~> 1.3"])
96
- s.add_runtime_dependency(%q<logging>, [">= 1.8.2", "~> 1.8"])
97
- s.add_runtime_dependency(%q<git>, [">= 1.2.8", "~> 1.2"])
98
- s.add_runtime_dependency(%q<sinatra>, [">= 1.4.5", "~> 1.4.5"])
99
- s.add_runtime_dependency(%q<thin>, [">= 1.6.3", "~> 1.6.3"])
100
- s.add_runtime_dependency(%q<nokogiri>, [">= 1.6.3", "~> 1.6.3"])
101
- s.add_runtime_dependency(%q<slop>, [">= 4.0.0", "~> 4.0.0"])
102
- s.add_runtime_dependency(%q<nutella_lib>, [">= 0.4.6", "~> 0.4.6"])
103
- s.add_development_dependency(%q<shoulda>, [">= 3", "~> 3"])
104
- s.add_development_dependency(%q<yard>, [">= 0.8.7", "~> 0.8"])
105
- s.add_development_dependency(%q<rdoc>, [">= 4.0", "~> 4.0"])
106
- s.add_development_dependency(%q<bundler>, [">= 1.0", "~> 1.0"])
107
- s.add_development_dependency(%q<jeweler>, [">= 2.0.1", "~> 2.0.1"])
108
- s.add_development_dependency(%q<simplecov>, [">= 0", "~> 0"])
157
+ s.add_runtime_dependency(%q<semantic>, ["~> 1.4"])
158
+ s.add_runtime_dependency(%q<logging>, ["~> 1.8"])
159
+ s.add_runtime_dependency(%q<git>, ["~> 1.2"])
160
+ s.add_runtime_dependency(%q<sinatra>, ["~> 1.4"])
161
+ s.add_runtime_dependency(%q<thin>, ["~> 1.6"])
162
+ s.add_runtime_dependency(%q<nokogiri>, ["~> 1.6"])
163
+ s.add_runtime_dependency(%q<slop>, ["~> 4.0"])
164
+ s.add_runtime_dependency(%q<nutella_lib>, ["~> 0.4.10"])
165
+ s.add_development_dependency(%q<shoulda>, ["~> 3.0"])
166
+ s.add_development_dependency(%q<yard>, ["~> 0.8"])
167
+ s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
168
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
169
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
170
+ s.add_development_dependency(%q<simplecov>, ["~> 0.9"])
109
171
  else
110
- s.add_dependency(%q<semantic>, [">= 1.3", "~> 1.3"])
111
- s.add_dependency(%q<logging>, [">= 1.8.2", "~> 1.8"])
112
- s.add_dependency(%q<git>, [">= 1.2.8", "~> 1.2"])
113
- s.add_dependency(%q<sinatra>, [">= 1.4.5", "~> 1.4.5"])
114
- s.add_dependency(%q<thin>, [">= 1.6.3", "~> 1.6.3"])
115
- s.add_dependency(%q<nokogiri>, [">= 1.6.3", "~> 1.6.3"])
116
- s.add_dependency(%q<slop>, [">= 4.0.0", "~> 4.0.0"])
117
- s.add_dependency(%q<nutella_lib>, [">= 0.4.6", "~> 0.4.6"])
118
- s.add_dependency(%q<shoulda>, [">= 3", "~> 3"])
119
- s.add_dependency(%q<yard>, [">= 0.8.7", "~> 0.8"])
120
- s.add_dependency(%q<rdoc>, [">= 4.0", "~> 4.0"])
121
- s.add_dependency(%q<bundler>, [">= 1.0", "~> 1.0"])
122
- s.add_dependency(%q<jeweler>, [">= 2.0.1", "~> 2.0.1"])
123
- s.add_dependency(%q<simplecov>, [">= 0", "~> 0"])
172
+ s.add_dependency(%q<semantic>, ["~> 1.4"])
173
+ s.add_dependency(%q<logging>, ["~> 1.8"])
174
+ s.add_dependency(%q<git>, ["~> 1.2"])
175
+ s.add_dependency(%q<sinatra>, ["~> 1.4"])
176
+ s.add_dependency(%q<thin>, ["~> 1.6"])
177
+ s.add_dependency(%q<nokogiri>, ["~> 1.6"])
178
+ s.add_dependency(%q<slop>, ["~> 4.0"])
179
+ s.add_dependency(%q<nutella_lib>, ["~> 0.4.10"])
180
+ s.add_dependency(%q<shoulda>, ["~> 3.0"])
181
+ s.add_dependency(%q<yard>, ["~> 0.8"])
182
+ s.add_dependency(%q<rdoc>, ["~> 4.0"])
183
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
184
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
185
+ s.add_dependency(%q<simplecov>, ["~> 0.9"])
124
186
  end
125
187
  else
126
- s.add_dependency(%q<semantic>, [">= 1.3", "~> 1.3"])
127
- s.add_dependency(%q<logging>, [">= 1.8.2", "~> 1.8"])
128
- s.add_dependency(%q<git>, [">= 1.2.8", "~> 1.2"])
129
- s.add_dependency(%q<sinatra>, [">= 1.4.5", "~> 1.4.5"])
130
- s.add_dependency(%q<thin>, [">= 1.6.3", "~> 1.6.3"])
131
- s.add_dependency(%q<nokogiri>, [">= 1.6.3", "~> 1.6.3"])
132
- s.add_dependency(%q<slop>, [">= 4.0.0", "~> 4.0.0"])
133
- s.add_dependency(%q<nutella_lib>, [">= 0.4.6", "~> 0.4.6"])
134
- s.add_dependency(%q<shoulda>, [">= 3", "~> 3"])
135
- s.add_dependency(%q<yard>, [">= 0.8.7", "~> 0.8"])
136
- s.add_dependency(%q<rdoc>, [">= 4.0", "~> 4.0"])
137
- s.add_dependency(%q<bundler>, [">= 1.0", "~> 1.0"])
138
- s.add_dependency(%q<jeweler>, [">= 2.0.1", "~> 2.0.1"])
139
- s.add_dependency(%q<simplecov>, [">= 0", "~> 0"])
188
+ s.add_dependency(%q<semantic>, ["~> 1.4"])
189
+ s.add_dependency(%q<logging>, ["~> 1.8"])
190
+ s.add_dependency(%q<git>, ["~> 1.2"])
191
+ s.add_dependency(%q<sinatra>, ["~> 1.4"])
192
+ s.add_dependency(%q<thin>, ["~> 1.6"])
193
+ s.add_dependency(%q<nokogiri>, ["~> 1.6"])
194
+ s.add_dependency(%q<slop>, ["~> 4.0"])
195
+ s.add_dependency(%q<nutella_lib>, ["~> 0.4.10"])
196
+ s.add_dependency(%q<shoulda>, ["~> 3.0"])
197
+ s.add_dependency(%q<yard>, ["~> 0.8"])
198
+ s.add_dependency(%q<rdoc>, ["~> 4.0"])
199
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
200
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
201
+ s.add_dependency(%q<simplecov>, ["~> 0.9"])
140
202
  end
141
203
  end
142
204
 
@@ -180,7 +180,7 @@ module Nutella
180
180
  rescue JSON::ParserError
181
181
  # Make sure the message is JSON, if not drop the message
182
182
  return
183
- rescue
183
+ rescue ArgumentError
184
184
  # Check the passed callback has the right number of arguments
185
185
  STDERR.puts "The callback you passed to subscribe has the #{$!}: it needs 'payload', 'app_id', 'run_id' and 'from'"
186
186
  end
@@ -189,8 +189,8 @@ module Nutella
189
189
  Nutella::Net.subscriptions.push padded_channel
190
190
  Nutella::Net.callbacks.push mqtt_cb
191
191
  Nutella.mqtt.subscribe( padded_channel, mqtt_cb )
192
- # Notify subscriptions bot
193
- Nutella::Net.publish_to('subscriptions', {'channel' => padded_channel}, nil, nil)
192
+ # Notify subscription
193
+ Nutella::Net.publish_to('subscriptions', {'type' => 'subscribe', 'channel' => padded_channel}, nil, nil)
194
194
  end
195
195
 
196
196
 
@@ -259,13 +259,16 @@ module Nutella
259
259
  rescue JSON::ParserError
260
260
  # Make sure that request contains JSON, if not drop the message
261
261
  return
262
- rescue
262
+ rescue ArgumentError
263
263
  # Check the passed callback has the right number of arguments
264
264
  STDERR.puts "The callback you passed to subscribe has the #{$!}: it needs 'request', 'app_id', 'run_id' and 'from'"
265
265
  end
266
266
  end
267
267
  # Subscribe to the channel
268
+ puts padded_channel
268
269
  Nutella.mqtt.subscribe( padded_channel, mqtt_cb )
270
+ # Notify subscription
271
+ Nutella::Net.publish_to('subscriptions', {'type' => 'handle_requests', 'channel' => padded_channel}, nil, nil)
269
272
  end
270
273
 
271
274
  # @!endgroup
@@ -380,7 +383,7 @@ module Nutella
380
383
  rescue JSON::ParserError
381
384
  # Make sure the message is JSON, if not drop the message
382
385
  return
383
- rescue
386
+ rescue ArgumentError
384
387
  # Check the passed callback has the right number of arguments
385
388
  STDERR.puts "The callback you passed to subscribe has the #{$!}: it needs 'payload', 'app_id' and 'from'"
386
389
  end
@@ -389,8 +392,8 @@ module Nutella
389
392
  Nutella::Net.subscriptions.push padded_channel
390
393
  Nutella::Net.callbacks.push mqtt_cb
391
394
  Nutella.mqtt.subscribe( padded_channel, mqtt_cb )
392
- # Notify subscriptions bot
393
- Nutella::Net.publish_to('subscriptions', {'channel' => padded_channel}, nil, nil)
395
+ # Notify subscription
396
+ Nutella::Net.publish_to('subscriptions', {'type' => 'subscribe', 'channel' => padded_channel}, nil, nil)
394
397
  end
395
398
 
396
399
 
@@ -454,33 +457,34 @@ module Nutella
454
457
  rescue JSON::ParserError
455
458
  # Make sure that request contains JSON, if not drop the message
456
459
  return
457
- rescue
460
+ rescue ArgumentError
458
461
  # Check the passed callback has the right number of arguments
459
462
  STDERR.puts "The callback you passed to subscribe has the #{$!}: it needs 'request', 'app_id' and 'from'"
460
463
  end
461
464
  end
462
465
  # Subscribe to the channel
463
466
  Nutella.mqtt.subscribe( padded_channel, mqtt_cb )
467
+ # Notify subscription
468
+ Nutella::Net.publish_to('subscriptions', {'type' => 'handle_requests', 'channel' => padded_channel}, nil, nil)
464
469
  end
465
470
 
466
471
  # @!endgroup
467
472
 
473
+
468
474
  # ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
469
475
 
476
+
470
477
  # Listens for incoming messages. All this function
471
478
  # does is to put the thread to sleep and wait for something to
472
479
  # happen over the network to wake up.
473
480
  def self.listen
474
- begin
475
- sleep
476
- rescue Interrupt
477
- # Simply returns once interrupted
478
- end
481
+ Nutella::Net.listen
479
482
  end
480
483
 
481
484
 
482
485
  private
483
486
 
487
+
484
488
  def self.extract_run_id_and_app_id( mqtt_channel )
485
489
  sp = mqtt_channel.sub('/nutella/apps/', '').split('/')
486
490
  return sp[0], sp[2]