class RenderSync::Clients::Pusher::Message

Attributes

channel[RW]
data[RW]

Public Class Methods

batch_publish(messages) click to toggle source
# File lib/render_sync/clients/pusher.rb, line 46
def self.batch_publish(messages)
  messages.each do |message|
    message.publish
  end
end
new(channel, data) click to toggle source
# File lib/render_sync/clients/pusher.rb, line 52
def initialize(channel, data)
  self.channel = channel
  self.data = data
end

Public Instance Methods

publish() click to toggle source
# File lib/render_sync/clients/pusher.rb, line 57
def publish
  if RenderSync.async?
    publish_asynchronous
  else
    publish_synchronous
  end
end
publish_asynchronous() click to toggle source
# File lib/render_sync/clients/pusher.rb, line 69
def publish_asynchronous
  RenderSync.reactor.perform do
    ::Pusher.trigger_async([channel], 'sync', data)
  end
end
publish_synchronous() click to toggle source
# File lib/render_sync/clients/pusher.rb, line 65
def publish_synchronous
  ::Pusher.trigger([channel], 'sync', data)
end