Skip to content

Commit

Permalink
Simplify client connection closing
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Apr 9, 2015
1 parent a4f96c3 commit 662c064
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/action_cable/connection/base.rb
Expand Up @@ -44,10 +44,7 @@ def process
@websocket.on(:close) do |event|
logger.info "[ActionCable] #{finished_request_message}"

worker_pool.async.invoke(self, :cleanup_subscriptions)
worker_pool.async.invoke(self, :cleanup_internal_redis_subscriptions)
worker_pool.async.invoke(self, :disconnect) if respond_to?(:disconnect)

worker_pool.async.invoke(self, :close_client_connection)
EventMachine.cancel_timer(@ping_timer) if @ping_timer
end

Expand Down Expand Up @@ -98,6 +95,12 @@ def initialize_client
worker_pool.async.invoke(self, :received_data, @pending_messages.shift) until @pending_messages.empty?
end

def close_client_connection
cleanup_subscriptions
cleanup_internal_redis_subscriptions
disconnect if respond_to?(:disconnect)
end

def broadcast_ping_timestamp
broadcast({ identifier: '_ping', message: Time.now.to_i }.to_json)
end
Expand Down

0 comments on commit 662c064

Please sign in to comment.