Sha256: 8568c587883d6b19ac3b91872b080b70d2737b6494ccb67a86171c2f3d5a4731

Contents?: true

Size: 919 Bytes

Versions: 7

Compression:

Stored size: 919 Bytes

Contents

module APN
  # This is the class that's actually enqueued via Resque when user calls +APN.notify+.
  # It gets added to the +apple_server_notifications+ Resque queue, which should only be operated on by
  # workers of the +APN::Sender+ class.
  class NotificationJob
    # Behind the scenes, this is the name of our Resque queue
    @queue = APN::QUEUE_NAME

    # Build a notification from arguments and send to Apple
    def self.perform(token, opts)
      msg = APN::Notification.new(token, opts)
      raise "Invalid notification options (did you provide :alert, :badge, or :sound?): #{opts.inspect}" unless msg.valid?

      worker.send_to_apple( msg )
    end


    # Only execute this job in specialized APN::Sender workers, since
    # standard Resque workers don't maintain the persistent TCP connection.
    extend Resque::Plugins::AccessWorkerFromJob
    self.required_worker_class = 'APN::Sender'
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
apn_sender-1.0.5 lib/apn/notification_job.rb
apn_sender-1.0.4 lib/apn/notification_job.rb
apn_sender-1.0.3 lib/apn/notification_job.rb
hackedunit-apn_sender-1.1.0 lib/apn/notification_job.rb
apn_sender-1.0.2 lib/apn/notification_job.rb
apn_sender-1.0.1 lib/apn/notification_job.rb
apn_sender-1.0.0 lib/apn/notification_job.rb