Class: Punchblock::Command::Join

Inherits:
Punchblock::CommandNode show all
Defined in:
lib/punchblock/command/join.rb

Constant Summary collapse

VALID_DIRECTIONS =
[:duplex, :send, :recv].freeze

Constants inherited from RayoNode

RayoNode::InvalidNodeError

Instance Attribute Summary

Attributes inherited from RayoNode

#client, #component_id, #connection, #domain, #original_component, #target_call_id, #target_mixer_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Punchblock::CommandNode

#initialize, #response, #response=, #write_attr

Methods inherited from RayoNode

class_from_registration, #eql?, import, #inspect, register, #source

Constructor Details

This class inherits a constructor from Punchblock::CommandNode

Class Method Details

.new(options = {}) ⇒ Command::Join

Create a join command

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :call_id (String, Optional)

    the call ID to join

  • :mixer_name (String, Optional)

    the mixer name to join

  • :direction (Symbol, Optional)

    the direction in which media should flow

  • :media (Symbol, Optional)

    the method by which to negotiate media

Returns:



21
22
23
24
25
26
27
28
29
30
# File 'lib/punchblock/command/join.rb', line 21

def self.new(options = {})
  super().tap do |new_node|
    case options
    when Nokogiri::XML::Node
      new_node.inherit options
    when Hash
      options.each_pair { |k,v| new_node.send :"#{k}=", v }
    end
  end
end

Instance Method Details

#call_idString

Returns the call ID to join.

Returns:

  • (String)

    the call ID to join



34
35
36
# File 'lib/punchblock/command/join.rb', line 34

def call_id
  read_attr :'call-id'
end

#call_id=(other) ⇒ Object

Parameters:

  • other (String)

    the call ID to join



40
41
42
# File 'lib/punchblock/command/join.rb', line 40

def call_id=(other)
  write_attr :'call-id', other
end

#directionString

Returns the direction in which media should flow.

Returns:

  • (String)

    the direction in which media should flow



58
59
60
# File 'lib/punchblock/command/join.rb', line 58

def direction
  read_attr :direction, :to_sym
end

#direction=(direction) ⇒ Object

Parameters:

  • other (String)

    the direction in which media should flow. Can be :duplex, :recv or :send



64
65
66
67
68
69
# File 'lib/punchblock/command/join.rb', line 64

def direction=(direction)
  if direction && !VALID_DIRECTIONS.include?(direction.to_sym)
    raise ArgumentError, "Invalid Direction (#{direction}), use: #{VALID_DIRECTIONS*' '}"
  end
  write_attr :direction, direction 
end

#inspect_attributesObject

:nodoc:



83
84
85
# File 'lib/punchblock/command/join.rb', line 83

def inspect_attributes # :nodoc:
  [:call_id, :mixer_name, :direction, :media] + super
end

#mediaString

Returns the method by which to negotiate media.

Returns:

  • (String)

    the method by which to negotiate media



73
74
75
# File 'lib/punchblock/command/join.rb', line 73

def media
  read_attr :media, :to_sym
end

#media=(other) ⇒ Object

Parameters:

  • other (String)

    the method by which to negotiate media. Can be :direct or :bridge



79
80
81
# File 'lib/punchblock/command/join.rb', line 79

def media=(other)
  write_attr :media, other
end

#mixer_nameString

Returns the mixer name to join.

Returns:

  • (String)

    the mixer name to join



46
47
48
# File 'lib/punchblock/command/join.rb', line 46

def mixer_name
  read_attr :'mixer-name'
end

#mixer_name=(other) ⇒ Object

Parameters:

  • other (String)

    the mixer name to join



52
53
54
# File 'lib/punchblock/command/join.rb', line 52

def mixer_name=(other)
  write_attr :'mixer-name', other
end