roda-component 0.1.27 → 0.1.28

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34af2117ec9844c79388172c7925327234a15420
4
- data.tar.gz: 47664199fa77227ee28102b6b3e7f0b79525f49e
3
+ metadata.gz: f394e3df58f2cc1e6ae4b050f1d3fa1c115e619a
4
+ data.tar.gz: 493c91445c9a9a4e609671c2e69b090cdb0a1671
5
5
  SHA512:
6
- metadata.gz: e1da41e5dd0a4abb369e5c51b3d6407f5dfe46686bd43e7a5f44ba1cddf75300ab2993ab485d712e815cf5418289c1bd9f0024c6d33c2e852582b2cb6eee0541
7
- data.tar.gz: 4bf89d4fb46a3d17ecab201d12e2fc462acb3baf2410ddbd857422f1ffc45dc5ab41600644c65ff720498c146ce38e37410339590e0d3d66c7fd1fef207e0589
6
+ metadata.gz: 1f69f31e023c2c386f62ac663e05965893df6be7da0b32c793da25d5b55fdecb98a64bba9be28f57acb95266cae653a95523c9b321ad8995e6f2e830a85fa342
7
+ data.tar.gz: 2da6028f1ab9951904757aebe7f7baa5452002a3585bd181e3c57c0fa9558c94837f7446612ff87bf03f71ee18cbd5a065c0b2cae85052a295cc7c6940578cb9
@@ -128,11 +128,12 @@ else
128
128
 
129
129
  case message['channel']
130
130
  when '/meta/connect'
131
+ callback.call message
132
+
131
133
  if session_id
132
134
  redis.call 'HSET', "#{key}/ids", private_id, public_id
133
135
  # puts redis.call 'HGETALL', "#{key}/ids"
134
136
  end
135
- callback.call message
136
137
  when '/meta/disconnect'
137
138
  callback.call message
138
139
 
@@ -203,8 +204,25 @@ else
203
204
  data = app.roda_component(:"#{component_name}", { trigger: (joining ? :join : :leave), public_id: public_id, private_id: private_id })
204
205
 
205
206
  url = "http#{request.env['SERVER_PORT'] == '443' ? 's' : ''}://#{request.env['SERVER_NAME']}:#{request.env['SERVER_PORT']}/faye"
206
- client = ::Faye::Client.new(url)
207
- client.publish "/components/#{component_name}", type: (joining ? 'join' : 'leave'), public_id: public_id, token: app.component_opts[:token], local: data
207
+ # client = ::Faye::Client.new(url)
208
+ # client.publish "/components/#{component_name}", type: (joining ? 'join' : 'leave'), public_id: public_id, token: app.component_opts[:token], local: data
209
+ # EM.run {
210
+ http = EM::HttpRequest.new(url).post(
211
+ head: {
212
+ 'content-type' => 'application/json'
213
+ },
214
+ body: {
215
+ channel: "/components/#{component_name}",
216
+ data: {
217
+ type: (joining ? 'join' : 'leave'), public_id: public_id, token: app.component_opts[:token], local: data }
218
+ }.to_json
219
+ )
220
+ # http.callback {
221
+ # ap http.response_header.status
222
+ # ap http.response_header
223
+ # ap http.response
224
+ # }
225
+ # }
208
226
  end
209
227
 
210
228
  # /components/:id/:comp/:action
@@ -1,5 +1,5 @@
1
1
  class Roda
2
2
  class Component
3
- VERSION = "0.1.27"
3
+ VERSION = "0.1.28"
4
4
  end
5
5
  end
@@ -110,7 +110,9 @@ class Roda
110
110
  def initialize(scope = false)
111
111
  @scope = scope
112
112
 
113
- if client?
113
+ if client? && !$component_opts[:faye][:"#{self.class._name}"]
114
+ $component_opts[:faye][:"#{self.class._name}"] = true
115
+
114
116
  $faye.subscribe "/components/#{self.class._name}" do |msg|
115
117
  msg = Native(msg)
116
118
 
@@ -91,6 +91,7 @@ class Roda
91
91
  end
92
92
 
93
93
  unless $component_opts[:comp][:"#{comp_name}"]
94
+ $component_opts[:faye] ||= {}
94
95
  $component_opts[:comp][:"#{comp_name}"] = true
95
96
  `$.getScript("/#{component_opts[:assets_route]}#{file_path}", function(){`
96
97
  Document.ready? do
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_runtime_dependency "opal", "~> 0.7.0.beta3"
22
22
  spec.add_runtime_dependency "opal-jquery", "~> 0.3.0.beta2"
23
23
  spec.add_runtime_dependency "redis-rack"
24
+ spec.add_runtime_dependency "rest-client"
24
25
  spec.add_runtime_dependency "faye", '~> 1.1.0'
25
26
  spec.add_runtime_dependency "faye-redis"
26
27
  spec.add_runtime_dependency "redic", "~> 1.1.1"
data/test/dummy/dummy.db CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.27
4
+ version: 0.1.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: faye
57
71
  requirement: !ruby/object:Gem::Requirement