Sha256: 96949b3fc16333fa1e06ead6d185b316c358099521d8ba7fcc6307e42d3be4eb

Contents?: true

Size: 781 Bytes

Versions: 4

Compression:

Stored size: 781 Bytes

Contents

require 'rhosync/ping'

module Rhosync
  module PingJob
    @queue = :ping
    
    # Perform a ping for all clients registered to a user
    def self.perform(params)
      user = User.load(params["user_id"])
      user.clients.members.each do |client_id|
        client = Client.load(client_id,{:source_name => '*'})
        params.merge!('device_port' => client.device_port,
          'device_pin' => client.device_pin)   
        if client.device_type and client.device_type.size > 0 and client.device_pin and client.device_pin.size > 0
          klass = Object.const_get(camelize(client.device_type.downcase))
          klass.ping(params) if klass
        else
          log "Skipping ping for non-registered client_id '#{client_id}'..."
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rhosync-2.1.2 lib/rhosync/jobs/ping_job.rb
rhosync-2.1.1 lib/rhosync/jobs/ping_job.rb
rhosync-2.1.0 lib/rhosync/jobs/ping_job.rb
rhosync-2.1.0.beta.2 lib/rhosync/jobs/ping_job.rb