mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge remote-tracking branch 'origin/celluloid'
Conflicts: lib/action_cable/server.rb
This commit is contained in:
commit
247453adec
1 changed files with 12 additions and 8 deletions
|
@ -6,6 +6,8 @@ module ActionCable
|
||||||
class_attribute :worker_pool_size
|
class_attribute :worker_pool_size
|
||||||
self.worker_pool_size = 100
|
self.worker_pool_size = 100
|
||||||
|
|
||||||
|
cattr_accessor(:logger, instance_reader: true) { Rails.logger }
|
||||||
|
|
||||||
PING_INTERVAL = 3
|
PING_INTERVAL = 3
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
@ -75,6 +77,7 @@ module ActionCable
|
||||||
end
|
end
|
||||||
|
|
||||||
def broadcast(data)
|
def broadcast(data)
|
||||||
|
logger.info "Sending data: #{data}"
|
||||||
@websocket.send data
|
@websocket.send data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -94,24 +97,25 @@ module ActionCable
|
||||||
subscription_klass = registered_channels.detect { |channel_klass| channel_klass.find_name == id_options[:channel] }
|
subscription_klass = registered_channels.detect { |channel_klass| channel_klass.find_name == id_options[:channel] }
|
||||||
|
|
||||||
if subscription_klass
|
if subscription_klass
|
||||||
|
logger.info "Subscribing to channel: #{id_key}"
|
||||||
@subscriptions[id_key] = subscription_klass.new(self, id_key, id_options)
|
@subscriptions[id_key] = subscription_klass.new(self, id_key, id_options)
|
||||||
else
|
else
|
||||||
# No channel found
|
logger.error "Unable to subscribe to channel: #{id_key}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_message(message)
|
def process_message(message)
|
||||||
id_key = message['identifier']
|
if @subscriptions[message['identifier']]
|
||||||
|
@subscriptions[message['identifier']].receive(ActiveSupport::JSON.decode message['data'])
|
||||||
if @subscriptions[id_key]
|
else
|
||||||
@subscriptions[id_key].receive(ActiveSupport::JSON.decode message['data'])
|
logger.error "Unable to process message: #{message}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unsubscribe_channel(data)
|
def unsubscribe_channel(data)
|
||||||
id_key = data['identifier']
|
logger.info "Unsubscribing from channel: #{data['identifier']}"
|
||||||
@subscriptions[id_key].unsubscribe
|
@subscriptions[data['identifier']].unsubscribe
|
||||||
@subscriptions.delete(id_key)
|
@subscriptions.delete(data['identifier'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def invalid_request
|
def invalid_request
|
||||||
|
|
Loading…
Reference in a new issue