From f8638f789a1cbd33205cdce0dd24f2aee3d69a25 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 21 Jun 2015 21:41:43 +0200 Subject: Rename callback hooks to match setup And make it all private --- lib/action_cable/connection/base.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/action_cable/connection/base.rb b/lib/action_cable/connection/base.rb index 175b596241..f6beda1c57 100644 --- a/lib/action_cable/connection/base.rb +++ b/lib/action_cable/connection/base.rb @@ -33,7 +33,7 @@ module ActionCable @websocket.on(:open) do |event| transmit_ping_timestamp @ping_timer = EventMachine.add_periodic_timer(PING_INTERVAL) { transmit_ping_timestamp } - worker_pool.async.invoke(self, :initialize_connection) + worker_pool.async.invoke(self, :on_open) end @websocket.on(:message) do |event| @@ -51,7 +51,7 @@ module ActionCable @websocket.on(:close) do |event| logger.info finished_request_message - worker_pool.async.invoke(self, :close_connection) + worker_pool.async.invoke(self, :on_close) EventMachine.cancel_timer(@ping_timer) if @ping_timer end @@ -110,7 +110,9 @@ module ActionCable request.cookie_jar end - def initialize_connection + + private + def on_open server.add_connection(self) connect if respond_to?(:connect) @@ -120,7 +122,7 @@ module ActionCable worker_pool.async.invoke(self, :receive, @pending_messages.shift) until @pending_messages.empty? end - def close_connection + def on_close server.remove_connection(self) cleanup_subscriptions -- cgit v1.2.3