我知道在ActionCable中ping是这样的:
def beat
transmit type: ActionCable::INTERNAL[:message_types][:ping], message: Time.now.to_i
end
但是当我尝试在连接上传输时,只有一个连接用transmit
来获取我的消息?
def connect
self.uuid = SecureRandom.uuid
transmit({'title': 'players_online', 'message': 'A new user has been subscribed'})
end
答案 0 :(得分:1)
实际上很容易:
ActionCable.server.connections.each do |connection|
connection.transmit({'title': 'players_online', 'message': ActionCable.server.connections.size})
end