From 1b090cf6b215e334ba62b476d14283a49fca8cab Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 5 Feb 2015 20:51:32 +0530 Subject: Helper method for worker_pool --- lib/action_cable/channel/base.rb | 7 ++++++- lib/action_cable/server.rb | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/action_cable') 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'] -- cgit v1.2.3