Class: Punchblock::Component::ComponentNode
Constant Summary
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
Instance Method Summary
collapse
#inspect_attributes, new, #response, #write_attr
Methods inherited from RayoNode
class_from_registration, #eql?, import, #inspect, #inspect_attributes, new, register, #source
Constructor Details
Returns a new instance of ComponentNode.
8
9
10
11
12
|
# File 'lib/punchblock/component/component_node.rb', line 8
def initialize(*args)
super
@complete_event_resource = FutureResource.new
register_internal_handlers
end
|
Instance Method Details
#add_event(event) ⇒ Object
21
22
23
|
# File 'lib/punchblock/component/component_node.rb', line 21
def add_event(event)
trigger_handler :internal, event
end
|
#complete_event(timeout = nil) ⇒ Object
46
47
48
|
# File 'lib/punchblock/component/component_node.rb', line 46
def complete_event(timeout = nil)
@complete_event_resource.resource timeout
end
|
#complete_event=(other) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/punchblock/component/component_node.rb', line 50
def complete_event=(other)
return if @complete_event_resource.set_yet?
client.delete_component_registration self if client
complete!
@complete_event_resource.resource = other
end
|
#register_event_handler(*guards, &block) ⇒ Object
29
30
31
|
# File 'lib/punchblock/component/component_node.rb', line 29
def register_event_handler(*guards, &block)
register_handler :event, *guards, &block
end
|
#register_internal_handlers ⇒ Object
14
15
16
17
18
19
|
# File 'lib/punchblock/component/component_node.rb', line 14
def register_internal_handlers
register_handler :internal, Event::Complete do |event|
self.complete_event = event
throw :pass
end
end
|
#response=(other) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/punchblock/component/component_node.rb', line 38
def response=(other)
if other.is_a?(Ref)
@component_id = other.id
client.register_component self if client
end
super
end
|
#stop!(options = {}) ⇒ Object
Sends a Rayo stop message for the current component
69
70
71
72
|
# File 'lib/punchblock/component/component_node.rb', line 69
def stop!(options = {})
raise InvalidActionError, "Cannot stop a #{self.class.name.split("::").last} that is #{state}" unless executing?
stop_action.tap { |action| write_action action }
end
|
#stop_action ⇒ Stop
Create a Rayo stop message
62
63
64
|
# File 'lib/punchblock/component/component_node.rb', line 62
def stop_action
Stop.new :component_id => component_id, :target_call_id => target_call_id
end
|
#trigger_event_handler(event) ⇒ Object
25
26
27
|
# File 'lib/punchblock/component/component_node.rb', line 25
def trigger_event_handler(event)
trigger_handler :event, event
end
|
#write_action(action) ⇒ Object
33
34
35
36
|
# File 'lib/punchblock/component/component_node.rb', line 33
def write_action(action)
client.execute_command action, :target_call_id => target_call_id, :component_id => component_id
action
end
|