aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_cable/worker.rb
blob: 1a8bee974bf9deb7bdf61812d9377f78ee99816b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module ActionCable
  class Worker
    include ActiveSupport::Callbacks
    include Celluloid

    define_callbacks :work

    def received_data(connection, data)
      run_callbacks :work do
        connection.received_data(data)
      end
    end

    def cleanup_subscriptions(connection)
      run_callbacks :work do
        connection.cleanup_subscriptions
      end
    end

    def run_periodic_timer(channel, callback)
      run_callbacks :work do
        callback.respond_to?(:call) ? channel.instance_exec(&callback) : channel.send(callback)
      end
    end

  end
end