Class: Adhearsion::Calls
Overview
This manages the list of calls the Adhearsion service receives
Instance Method Summary collapse
- #<<(call) ⇒ Object
- #any? ⇒ Boolean
- #clear! ⇒ Object
-
#find(id) ⇒ Object
Searches all active calls by their unique_identifier.
-
#initialize ⇒ Calls
constructor
A new instance of Calls.
- #remove_inactive_call(call) ⇒ Object
- #size ⇒ Object
- #to_a ⇒ Object
- #with_tag(tag) ⇒ Object
Constructor Details
#initialize ⇒ Calls
Returns a new instance of Calls.
27 28 29 30 |
# File 'lib/adhearsion/voip/call.rb', line 27 def initialize @semaphore = Monitor.new @calls = {} end |
Instance Method Details
#<<(call) ⇒ Object
32 33 34 35 36 |
# File 'lib/adhearsion/voip/call.rb', line 32 def <<(call) atomically do calls[call.unique_identifier] = call end end |
#any? ⇒ Boolean
38 39 40 41 42 |
# File 'lib/adhearsion/voip/call.rb', line 38 def any? atomically do !calls.empty? end end |
#clear! ⇒ Object
64 65 66 67 68 |
# File 'lib/adhearsion/voip/call.rb', line 64 def clear! atomically do calls.clear end end |
#find(id) ⇒ Object
Searches all active calls by their unique_identifier. See Call#unique_identifier. Is this actually by channel?
58 59 60 61 62 |
# File 'lib/adhearsion/voip/call.rb', line 58 def find(id) atomically do return calls[id] end end |
#remove_inactive_call(call) ⇒ Object
50 51 52 53 54 |
# File 'lib/adhearsion/voip/call.rb', line 50 def remove_inactive_call(call) atomically do calls.delete call.unique_identifier end end |
#size ⇒ Object
44 45 46 47 48 |
# File 'lib/adhearsion/voip/call.rb', line 44 def size atomically do calls.size end end |
#to_a ⇒ Object
78 79 80 |
# File 'lib/adhearsion/voip/call.rb', line 78 def to_a calls.values end |
#with_tag(tag) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/adhearsion/voip/call.rb', line 70 def with_tag(tag) atomically do calls.inject(Array.new) do |calls_with_tag,(key,call)| call.tagged_with?(tag) ? calls_with_tag << call : calls_with_tag end end end |