aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_cable
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2015-02-05 20:51:32 +0530
committerPratik Naik <pratiknaik@gmail.com>2015-02-05 20:51:32 +0530
commit1b090cf6b215e334ba62b476d14283a49fca8cab (patch)
tree6150cab521678aa8f83d2d396281ef0da8ce0c46 /lib/action_cable
parent41e4396a5549399eb808d74086cb6f4b9471b882 (diff)
downloadrails-1b090cf6b215e334ba62b476d14283a49fca8cab.tar.gz
rails-1b090cf6b215e334ba62b476d14283a49fca8cab.tar.bz2
rails-1b090cf6b215e334ba62b476d14283a49fca8cab.zip
Helper method for worker_pool
Diffstat (limited to 'lib/action_cable')
-rw-r--r--lib/action_cable/channel/base.rb7
-rw-r--r--lib/action_cable/server.rb8
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb
index a3aa4df2ad..832c8cc314 100644
--- a/lib/action_cable/channel/base.rb
+++ b/lib/action_cable/channel/base.rb
@@ -67,7 +67,7 @@ module ActionCable
def start_periodic_timers
self.class.periodic_timers.each do |callback, options|
@_active_periodic_timers << EventMachine::PeriodicTimer.new(options[:every]) do
- connection.class.worker_pool.async.run_periodic_timer(self, callback)
+ worker_pool.async.run_periodic_timer(self, callback)
end
end
end
@@ -75,6 +75,11 @@ module ActionCable
def stop_periodic_timers
@_active_periodic_timers.each {|t| t.cancel }
end
+
+ def worker_pool
+ connection.worker_pool
+ end
+
end
end
diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb
index d1b7e14b53..b6ea201b52 100644
--- a/lib/action_cable/server.rb
+++ b/lib/action_cable/server.rb
@@ -32,11 +32,11 @@ module ActionCable
@websocket.on(:message) do |event|
message = event.data
- self.class.worker_pool.async.received_data(self, message) if message.is_a?(String)
+ worker_pool.async.received_data(self, message) if message.is_a?(String)
end
@websocket.on(:close) do |event|
- self.class.worker_pool.async.cleanup_subscriptions(self)
+ worker_pool.async.cleanup_subscriptions(self)
end
@websocket.rack_response
@@ -68,6 +68,10 @@ module ActionCable
@websocket.send data
end
+ def worker_pool
+ self.class.worker_pool
+ end
+
private
def subscribe_channel(data)
id_key = data['identifier']