lib/adhearsion/call.rb in adhearsion-2.4.0.beta1 vs lib/adhearsion/call.rb in adhearsion-2.4.0.beta2
- old
+ new
@@ -28,12 +28,25 @@
raise ExpiredError, "This call is expired and is no longer accessible"
end
end
end
- attr_reader :end_reason, :controllers, :variables, :start_time, :end_time
+ # @return [Symbol] the reason for the call ending
+ attr_reader :end_reason
+ # @return [Array<Adhearsion::CallController>] the set of call controllers executing on the call
+ attr_reader :controllers
+
+ # @return [Hash<String => String>] a collection of SIP headers set during the call
+ attr_reader :variables
+
+ # @return [Time] the time at which the call began. For inbound calls this is the time at which the call was offered to Adhearsion. For outbound calls it is the time at which the remote party answered.
+ attr_reader :start_time
+
+ # @return [Time] the time at which the call began. For inbound calls this is the time at which the call was offered to Adhearsion. For outbound calls it is the time at which the remote party answered.
+ attr_reader :end_time
+
delegate :[], :[]=, :to => :variables
delegate :to, :from, :to => :offer, :allow_nil => true
def initialize(offer = nil)
register_initial_handlers
@@ -55,10 +68,11 @@
# @return [String, nil] The globally unique ID for the call
#
def id
offer.target_call_id if offer
end
+ alias :to_s :id
#
# @return [String, nil] The domain on which the call resides
#
def domain
@@ -159,17 +173,31 @@
merge_headers event.headers
throw :pass
end
on_joined do |event|
- target = event.call_uri || event.mixer_name
+ if event.call_uri
+ target = event.call_uri
+ type = :call
+ else
+ target = event.mixer_name
+ type = :mixer
+ end
+ logger.info "Joined to #{type} #{target}"
@peers[target] = Adhearsion.active_calls[target]
signal :joined, target
end
on_unjoined do |event|
- target = event.call_uri || event.mixer_name
+ if event.call_uri
+ target = event.call_uri
+ type = :call
+ else
+ target = event.mixer_name
+ type = :mixer
+ end
+ logger.info "Unjoined from #{type} #{target}"
@peers.delete target
signal :unjoined, target
end
on_end do |event|
@@ -275,10 +303,11 @@
# @option target [String] call_uri The call ID to join to
# @option target [String] mixer_name The mixer to join to
# @param [Hash, Optional] options further options to be joined with
#
def join(target, options = {})
+ logger.info "Joining to #{target}"
command = Punchblock::Command::Join.new options.merge(join_options_with_target(target))
write_and_await_response command
end
##
@@ -287,10 +316,11 @@
# @param [Call, String, Hash] target the target to unjoin from. May be a Call object, a call ID (String, Hash) or a mixer name (Hash)
# @option target [String] call_uri The call ID to unjoin from
# @option target [String] mixer_name The mixer to unjoin from
#
def unjoin(target)
+ logger.info "Unjoining from #{target}"
command = Punchblock::Command::Unjoin.new join_options_with_target(target)
write_and_await_response command
end
# @private
@@ -364,14 +394,9 @@
# @private
def logger_id
"#{self.class}: #{id}@#{domain}"
end
- # @private
- def to_ary
- [current_actor]
- end
-
# @private
def inspect
attrs = [:offer, :end_reason, :commands, :variables, :controllers, :to, :from].map do |attr|
"#{attr}=#{send(attr).inspect}"
end