class Jason::Broadcaster

Attributes

channel[R]

Public Class Methods

new(channel) click to toggle source
# File lib/jason/broadcaster.rb, line 4
def initialize(channel)
  @channel = channel
end

Public Instance Methods

broadcast(message) click to toggle source
# File lib/jason/broadcaster.rb, line 12
def broadcast(message)
  if Jason.transport_service == :action_cable
    ActionCable.server.broadcast(channel, message)
  elsif Jason.transport_service == :pusher
    $redis_jason.rpush("jason:outbound_message_queue", { channel: pusher_channel_name, name: 'changed', data: message }.to_json)
    Jason::OutboundMessageQueueWorker.perform_async
  end
end
pusher_channel_name() click to toggle source
# File lib/jason/broadcaster.rb, line 8
def pusher_channel_name
  "private-#{Jason.pusher_channel_prefix}-#{channel}"
end