Class: OverSIP::SIP::Uac
Instance Attribute Summary
Attributes inherited from Client
Instance Method Summary collapse
- #receive_response(response) ⇒ Object
- #route(request, dst_host = nil, dst_port = nil, dst_transport = nil) ⇒ Object
Methods inherited from Client
#abort_routing, #add_target_to_blacklist, #clear_callbacks, #clear_on_canceled, #clear_on_error, #clear_on_failure_response, #clear_on_invite_timeout, #clear_on_provisional_response, #clear_on_success_response, #clear_on_target, #client_timeout, #connection_failed, #initialize, #invite_timeout, #on_canceled, #on_error, #on_failure_response, #on_invite_timeout, #on_provisional_response, #on_success_response, #on_target, #tls_validation_failed
Methods included from Logger
fg_system_msg2str, load_methods, #log_id
Constructor Details
This class inherits a constructor from OverSIP::SIP::Client
Instance Method Details
#receive_response(response) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/oversip/sip/uac.rb', line 51 def receive_response response log_system_debug "received response #{response.status_code}" if $oversip_debug if response.status_code < 200 run_on_provisional_response_cbs response elsif response.status_code >= 200 && response.status_code <= 299 run_on_success_response_cbs response elsif response.status_code >= 300 if response.status_code == 503 if @conf[:dns_failover_on_503] try_next_target nil, nil, response return else run_on_failure_response_cbs response end else run_on_failure_response_cbs response end end end |
#route(request, dst_host = nil, dst_port = nil, dst_transport = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/oversip/sip/uac.rb', line 5 def route request, dst_host=nil, dst_port=nil, dst_transport=nil unless (@request = request).is_a? ::OverSIP::SIP::UacRequest or @request.is_a? ::OverSIP::SIP::Request raise ::OverSIP::RuntimeError, "request must be a OverSIP::SIP::UacRequest or OverSIP::SIP::Request instance" end # The destination of the request is taken from: # - dst_xxx fields if given. # - The request.ruri (which is an OverSIP::SIP::Uri or OverSIP::SIP::NameAddr). # Otherwise raise an exception. @log_id = "UAC (proxy #{@conf[:name]})" # Force the destination. if dst_host dst_scheme = :sip dst_host_type = ::OverSIP::Utils.ip_type(dst_host) || :domain # Or use the Request URI. else dst_scheme = request.ruri.scheme dst_host = request.ruri.host dst_host_type = request.ruri.host_type dst_port = request.ruri.port dst_transport = request.ruri.transport_param end # If the destination uri_host is an IPv6 reference, convert it to real IPv6. if dst_host_type == :ipv6_reference dst_host = ::OverSIP::Utils.normalize_ipv6(dst_host, true) dst_host_type = :ipv6 end # Loockup in the DNS cache of this proxy. result = check_dns_cache dst_scheme, dst_host, dst_host_type, dst_port, dst_transport case result when true return else # It can be String or nil, so use it as dns_cache_key param. # Perform RFC 3263 procedures. do_dns result, @request.via_branch_id, dst_scheme, dst_host, dst_host_type, dst_port, dst_transport end end |