class Lookbook::Cable

def broadcast(message, payload = nil)

def broadcast(message, payload = nil)
  logger.debug message.to_s
  server.broadcast(message.to_s, payload.to_h)
end

def cable_config

def cable_config
  cable = ActionCable::Server::Configuration.new
  cable.cable = {adapter: "async"}.with_indifferent_access
  cable.mount_path = nil
  cable.connection_class = -> { Lookbook::Connection }
  cable.logger = logger
  cable
end

def full_mount_path

def full_mount_path
  "#{engine_mount_path}/#{mount_path}".gsub("//", "/")
end

def initialize(engine_mount_path, logger: Lookbook.logger)

def initialize(engine_mount_path, logger: Lookbook.logger)
  @engine_mount_path = engine_mount_path
  @logger = logger
  logger.info "Initializing websocket"
  if Gem::Version.new(Rails.version) >= Gem::Version.new(6.0)
    @server = ActionCable::Server::Base.new config: cable_config
  else
    @server = ActionCable::Server::Base.new
    @server.config = cable_config
  end
end

def mount_path

def mount_path
  "/cable"
end

def mountable?

def mountable?
  true
end