Class: Punchblock::Component::Tropo::Conference

Inherits:
ComponentNode show all
Defined in:
lib/punchblock/component/tropo/conference.rb

Defined Under Namespace

Modules: ActiveSpeaker Classes: Announcement, Complete, FinishedSpeaking, Kick, Music, OffHold, OnHold, Speaking

Instance Attribute Summary

Attributes inherited from ComponentNode

#complete_event

Attributes inherited from RayoNode

#call_id, #client, #component_id, #connection, #original_component

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ComponentNode

#add_event, #initialize, #register_event_handler, #register_initial_handlers, #response=, #stop!, #stop_action, #write_action

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::Component::ComponentNode

Class Method Details

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

Creates an Rayo conference command

Examples:

conference :name => 'the_one_true_conference', :terminator => '#'

returns:
  <conference xmlns="urn:xmpp:tropo:conference:1" name="the_one_true_conference" terminator="#"/>

Parameters:

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

Options Hash (options):

  • :name (String)

    room id to with which to create or join the conference

  • :announcement (Announcement, Hash, Optional)

    to play on entry

  • :music (Music, Hash, Optional)

    to play to the participant when no moderator is present

  • :mute (Boolean, Optional)

    If set to true, the user will be muted in the conference

  • :moderator (Boolean, Optional)

    Whether or not the conference should be moderated

  • :tone_passthrough (Boolean, Optional)

    Identifies whether or not conference members can hear the tone generated when a a key on the phone is pressed.

  • :terminator (String, Optional)

    This is the touch-tone key (also known as “DTMF digit”) used to exit the conference.

Returns:

  • (Command::Conference)

    a formatted Rayo conference command



26
27
28
29
30
31
32
33
# File 'lib/punchblock/component/tropo/conference.rb', line 26

def self.new(options = {})
  super().tap do |new_node|
    options.each_pair do |k,v|
      new_node.send :"#{k}=", v
    end
    new_node.register_hold_status_handlers
  end
end

Instance Method Details

#announcementAnnouncement

Returns the announcement to play to the participant on entry.

Returns:

  • (Announcement)

    the announcement to play to the participant on entry



108
109
110
111
# File 'lib/punchblock/component/tropo/conference.rb', line 108

def announcement
  node = find_first '//ns:announcement', :ns => self.registered_ns
  Announcement.new node if node
end

#announcement=(ann) ⇒ Object

Parameters:

Options Hash (ann):

  • :text (String)

    Text to speak to the caller as an announcement

  • :url (String)

    URL to play to the caller as an announcement



118
119
120
121
# File 'lib/punchblock/component/tropo/conference.rb', line 118

def announcement=(ann)
  ann = Announcement.new(ann) unless ann.is_a? Announcement
  self << ann
end

#inspect_attributesObject

:nodoc:



149
150
151
# File 'lib/punchblock/component/tropo/conference.rb', line 149

def inspect_attributes # :nodoc:
  [:name, :mute, :terminator, :tone_passthrough, :moderator, :announcement, :music] + super
end

#kick!(options = {}) ⇒ Object

Sends an Rayo kick message for the current Conference

Parameters:

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

Options Hash (options):

  • :message (String)

    to explain the reason for kicking

Raises:



307
308
309
310
311
312
# File 'lib/punchblock/component/tropo/conference.rb', line 307

def kick!(options = {})
  raise InvalidActionError, "Cannot kick a Conference that is not executing" unless executing?
  kick_action.tap do |action|
    write_action action
  end
end

#kick_action(options = {}) ⇒ Command::Conference::Kick

Create an Rayo conference kick message

Examples:

conf_obj.kick_action(:message => 'bye!').to_xml

returns:
  <kick xmlns="urn:xmpp:tropo:conference:1">bye!</kick>

Parameters:

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

Options Hash (options):

  • :message (String)

    to explain the reason for kicking

Returns:

  • (Command::Conference::Kick)

    an Rayo conference kick message



297
298
299
# File 'lib/punchblock/component/tropo/conference.rb', line 297

def kick_action(options = {})
  Kick.new options.merge(:component_id => component_id, :call_id => call_id)
end

#moderatorBoolean

Returns Whether or not the conference should be moderated.

Returns:

  • (Boolean)

    Whether or not the conference should be moderated



94
95
96
# File 'lib/punchblock/component/tropo/conference.rb', line 94

def moderator
  read_attr(:moderator) == 'true'
end

#moderator=(moderator) ⇒ Object

Parameters:

  • moderator (Boolean)

    Whether or not the conference should be moderated



101
102
103
# File 'lib/punchblock/component/tropo/conference.rb', line 101

def moderator=(moderator)
  write_attr :moderator, moderator.to_s
end

#musicMusic

Returns the music to play to the participant on entry if there’s no moderator present.

Returns:

  • (Music)

    the music to play to the participant on entry if there’s no moderator present



126
127
128
129
# File 'lib/punchblock/component/tropo/conference.rb', line 126

def music
  node = find_first '//ns:music', :ns => self.registered_ns
  Music.new node if node
end

#music=(m) ⇒ Object

Parameters:

Options Hash (m):

  • :text (String)

    Text to speak to the caller

  • :url (String)

    URL to play to the caller



136
137
138
139
# File 'lib/punchblock/component/tropo/conference.rb', line 136

def music=(m)
  m = Music.new(m) unless m.is_a? Announcement
  self << m
end

#muteBoolean

Returns If set to true, the user will be muted in the conference.

Returns:

  • (Boolean)

    If set to true, the user will be muted in the conference.



52
53
54
# File 'lib/punchblock/component/tropo/conference.rb', line 52

def mute
  read_attr(:mute) == 'true'
end

#mute!Object

Sends an Rayo mute message for the current Conference

Raises:



249
250
251
252
253
254
255
# File 'lib/punchblock/component/tropo/conference.rb', line 249

def mute!
  raise InvalidActionError, "Cannot mute a Conference that is already muted" if muted?
  mute_action.tap do |action|
    result = write_action action
    muted! if result
  end
end

#mute=(mute) ⇒ Object

Parameters:

  • mute (Boolean)

    If set to true, the user will be muted in the conference



59
60
61
# File 'lib/punchblock/component/tropo/conference.rb', line 59

def mute=(mute)
  write_attr :mute, mute.to_s
end

#mute_actionCommand::Conference::Mute

Create an Rayo mute message for the current conference

Examples:

conf_obj.mute_action.to_xml

returns:
  <mute xmlns="urn:xmpp:tropo:conference:1"/>

Returns:

  • (Command::Conference::Mute)

    an Rayo mute message



242
243
244
# File 'lib/punchblock/component/tropo/conference.rb', line 242

def mute_action
  Command::Mute.new :component_id => component_id, :call_id => call_id
end

#nameString

Returns the name of the conference.

Returns:

  • (String)

    the name of the conference



38
39
40
# File 'lib/punchblock/component/tropo/conference.rb', line 38

def name
  read_attr :name
end

#name=(name) ⇒ Object

Parameters:

  • name (String)

    of the conference



45
46
47
# File 'lib/punchblock/component/tropo/conference.rb', line 45

def name=(name)
  write_attr :name, name
end

#register_hold_status_handlersObject



153
154
155
156
157
158
159
160
161
162
163
# File 'lib/punchblock/component/tropo/conference.rb', line 153

def register_hold_status_handlers
  register_event_handler OnHold do |event|
    onhold!
    throw :pass
  end

  register_event_handler OffHold do |event|
    offhold!
    throw :pass
  end
end

#terminatorString

Returns This is the touch-tone key (also known as “DTMF digit”) used to exit the conference.

Returns:

  • (String)

    This is the touch-tone key (also known as “DTMF digit”) used to exit the conference.



66
67
68
# File 'lib/punchblock/component/tropo/conference.rb', line 66

def terminator
  read_attr :terminator
end

#terminator=(terminator) ⇒ Object

Parameters:

  • terminator (String)

    This is the touch-tone key (also known as “DTMF digit”) used to exit the conference.



73
74
75
# File 'lib/punchblock/component/tropo/conference.rb', line 73

def terminator=(terminator)
  write_attr :terminator, terminator
end

#tone_passthroughBoolean

Returns Identifies whether or not conference members can hear the tone generated when a a key on the phone is pressed.

Returns:

  • (Boolean)

    Identifies whether or not conference members can hear the tone generated when a a key on the phone is pressed.



80
81
82
# File 'lib/punchblock/component/tropo/conference.rb', line 80

def tone_passthrough
  read_attr('tone-passthrough') == 'true'
end

#tone_passthrough=(tone_passthrough) ⇒ Object

Parameters:

  • tone_passthrough (Boolean)

    Identifies whether or not conference members can hear the tone generated when a a key on the phone is pressed.



87
88
89
# File 'lib/punchblock/component/tropo/conference.rb', line 87

def tone_passthrough=(tone_passthrough)
  write_attr 'tone-passthrough', tone_passthrough.to_s
end

#unmute!Object

Sends an Rayo unmute message for the current Conference

Raises:



275
276
277
278
279
280
281
# File 'lib/punchblock/component/tropo/conference.rb', line 275

def unmute!
  raise InvalidActionError, "Cannot unmute a Conference that is not muted" unless muted?
  unmute_action.tap do |action|
    result = write_action action
    unmuted! if result
  end
end

#unmute_actionCommand::Conference::Unmute

Create an Rayo unmute message for the current conference

Examples:

conf_obj.unmute_action.to_xml

returns:
  <unmute xmlns="urn:xmpp:tropo:conference:1"/>

Returns:

  • (Command::Conference::Unmute)

    an Rayo unmute message



268
269
270
# File 'lib/punchblock/component/tropo/conference.rb', line 268

def unmute_action
  Command::Unmute.new :component_id => component_id, :call_id => call_id
end