Class: Adhearsion::Rayo::Component::ComponentNode
Instance Attribute Summary
Attributes inherited from RayoNode
#client, #connection, #original_component
Instance Method Summary
collapse
#response
Methods inherited from RayoNode
#==, class_from_registration, from_xml, #inherit, #inspect, #rayo_attributes, #rayo_children, register, #source, #to_rayo, #to_xml
Constructor Details
Returns a new instance of ComponentNode.
13
14
15
16
17
18
|
# File 'lib/adhearsion/rayo/component/component_node.rb', line 13
def initialize(*args)
super
@complete_event_resource = FutureResource.new
@mutex = Mutex.new
register_internal_handlers
end
|
Instance Method Details
#add_event(event) ⇒ Object
27
28
29
|
# File 'lib/adhearsion/rayo/component/component_node.rb', line 27
def add_event(event)
trigger_handler :internal, event
end
|
#complete_event(timeout = nil) ⇒ Object
55
56
57
|
# File 'lib/adhearsion/rayo/component/component_node.rb', line 55
def complete_event(timeout = nil)
@complete_event_resource.resource timeout
end
|
#complete_event=(other) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/adhearsion/rayo/component/component_node.rb', line 59
def complete_event=(other)
@mutex.synchronize do
return if @complete_event_resource.set_yet?
client.delete_component_registration self if client
complete!
@complete_event_resource.resource = other
end
rescue StateMachine::InvalidTransition => e
e.message << " for component #{self}"
raise e
end
|
#register_event_handler(*guards, &block) ⇒ Object
35
36
37
|
# File 'lib/adhearsion/rayo/component/component_node.rb', line 35
def register_event_handler(*guards, &block)
register_handler :event, *guards, &block
end
|
#register_internal_handlers ⇒ Object
20
21
22
23
24
25
|
# File 'lib/adhearsion/rayo/component/component_node.rb', line 20
def register_internal_handlers
register_handler :internal, Event::Complete do |event|
self.complete_event = event
throw :pass
end
end
|
#response=(other) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/adhearsion/rayo/component/component_node.rb', line 44
def response=(other)
@mutex.synchronize do
if other.is_a?(Ref)
@component_id = other.component_id
@source_uri = other.uri.to_s
client.register_component self if client
end
super
end
end
|
#stop!(options = {}) ⇒ Object
Sends a Rayo stop message for the current component
83
84
85
86
|
# File 'lib/adhearsion/rayo/component/component_node.rb', line 83
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
76
77
78
|
# File 'lib/adhearsion/rayo/component/component_node.rb', line 76
def stop_action
Stop.new :component_id => component_id, :target_call_id => target_call_id
end
|
#trigger_event_handler(event) ⇒ Object
31
32
33
|
# File 'lib/adhearsion/rayo/component/component_node.rb', line 31
def trigger_event_handler(event)
trigger_handler :event, event
end
|
#write_action(action) ⇒ Object
39
40
41
42
|
# File 'lib/adhearsion/rayo/component/component_node.rb', line 39
def write_action(action)
client.execute_command action, :target_call_id => target_call_id, :component_id => component_id
action
end
|