Class: OverSIP::SIP::RFC3263::SrvTargets

Inherits:
Array
  • Object
show all
Defined in:
lib/oversip/sip/rfc3263.rb

Overview

This is the object returned by Query#resolve.

Instance Method Summary collapse

Instance Method Details

#randomizeObject

Returns a SrvRandomizedTargets instance.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/oversip/sip/rfc3263.rb', line 21

def randomize
  ordered_targets = SrvRandomizedTargets.allocate

  self.each do |entries|
    if entries.size == 1
      entries[0].targets.each {|e| ordered_targets << e}
    else
      randomize_entries(entries.select {|e| e.weight > 0}, ordered_targets)
      entries.select {|e| e.weight.zero?}.shuffle.each {|e| ordered_targets << e[1]}
    end
  end

  return ordered_targets
end