mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make the remote connection use the broadcaster as well
This commit is contained in:
parent
8a2af53c8e
commit
a5d6bc0eb5
2 changed files with 10 additions and 8 deletions
|
@ -10,18 +10,16 @@ module ActionCable
|
||||||
end
|
end
|
||||||
|
|
||||||
def disconnect
|
def disconnect
|
||||||
redis.publish internal_redis_channel, { type: 'disconnect' }.to_json
|
server.broadcast_without_logging internal_redis_channel, type: 'disconnect'
|
||||||
end
|
end
|
||||||
|
|
||||||
def identifiers
|
def identifiers
|
||||||
@server.connection_identifiers
|
server.connection_identifiers
|
||||||
end
|
|
||||||
|
|
||||||
def redis
|
|
||||||
@server.threaded_redis
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
attr_reader :server
|
||||||
|
|
||||||
def set_identifier_instance_vars(ids)
|
def set_identifier_instance_vars(ids)
|
||||||
raise InvalidIdentifiersError unless valid_identifiers?(ids)
|
raise InvalidIdentifiersError unless valid_identifiers?(ids)
|
||||||
ids.each { |k,v| instance_variable_set("@#{k}", v) }
|
ids.each { |k,v| instance_variable_set("@#{k}", v) }
|
||||||
|
|
|
@ -19,8 +19,12 @@ module ActionCable
|
||||||
@server, @channel = server, channel
|
@server, @channel = server, channel
|
||||||
end
|
end
|
||||||
|
|
||||||
def broadcast(message, log: true)
|
def broadcast(message)
|
||||||
server.logger.info "[ActionCable] Broadcasting to #{channel}: #{message}" if log
|
server.logger.info "[ActionCable] Broadcasting to #{channel}: #{message}"
|
||||||
|
broadcast_without_logging(message)
|
||||||
|
end
|
||||||
|
|
||||||
|
def broadcast_without_logging(message)
|
||||||
server.redis_for_threads.publish channel, message.to_json
|
server.redis_for_threads.publish channel, message.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue