diff options
-rw-r--r-- | lib/action_cable/server.rb | 4 | ||||
-rw-r--r-- | lib/action_cable/worker.rb | 10 |
2 files changed, 4 insertions, 10 deletions
diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb index b6ea201b52..9a30c7d3bf 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 - worker_pool.async.received_data(self, message) if message.is_a?(String) + worker_pool.async.invoke(self, :received_data, message) if message.is_a?(String) end @websocket.on(:close) do |event| - worker_pool.async.cleanup_subscriptions(self) + worker_pool.async.invoke(self, :cleanup_subscriptions) end @websocket.rack_response diff --git a/lib/action_cable/worker.rb b/lib/action_cable/worker.rb index 1a8bee974b..6687af43a0 100644 --- a/lib/action_cable/worker.rb +++ b/lib/action_cable/worker.rb @@ -5,15 +5,9 @@ module ActionCable define_callbacks :work - def received_data(connection, data) + def invoke(receiver, method, *args) run_callbacks :work do - connection.received_data(data) - end - end - - def cleanup_subscriptions(connection) - run_callbacks :work do - connection.cleanup_subscriptions + receiver.send method, *args end end |