Skip to content

Commit

Permalink
update the reactor
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanRada committed Mar 28, 2021
1 parent 2060457 commit 552c4fa
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/celluloid_pubsub/reactor.rb
Expand Up @@ -329,10 +329,23 @@ def unsubscribe_clients(channel, _json_data)
def shutdown
@shutting_down = true
log_debug "#{self.class} tries to 'shutdown'"
@websocket.close if ENV['RACK_ENV'] != 'test' && @websocket.present? && !@websocket.closed?
@websocket.close if close_websocket? && @websocket.present? && !@websocket.closed?
terminate
end

# In tests we sometimes mock the websocket to b e a double
# in which case we can't call close on the double
# because it's outside of the test
# @see Celluloid.shutdown in spec_helper
#
# @return [void]
#
# @api public
def close_websocket?
return true if ENV['RACK_ENV'] != 'test'
defined?(Rspec::Mocks::Double) && !websocket.is_a?(Rspec::Mocks::Double)
end

# this method will add the current actor to the list of the subscribers {#add_subscriber_to_channel}
# and will write to the socket a message for succesful subscription
#
Expand Down

0 comments on commit 552c4fa

Please sign in to comment.