Class OverSIP::SIP::Proxy

An OverSIP::SIP::Proxy class instance is created for routing a received SIP request.

Parent class

OverSIP::SIP::Proxy inherits all the methods of OverSIP::SIP::Client.

Class instance methods

new(proxy_profile=:default_proxy)

Creates an instance of OverSIP::SIP::Proxy with the given profile.

Parameters

proxy_profile
Must be a Symbol or String with a Proxy profile name existing in proxies.conf. Otherwise an OverSIP::RuntimeError is raised. If no value is given then :default_proxy profile is used.

Example

proxy = OverSIP::SIP::Proxy.new :proxy_out

route(request, dst_host=nil, dst_port=nil, dst_transport=nil)

Routes the given SIP request to the given destination (if given) or by following common SIP routing procedures with the information retrieved from the SIP request (Route headers or Request-URI).

OverSIP performs RFC 3263 and RFC 5626 (Outbound) procedures for choosing the destination(s) of the SIP request.

Parameters

request
The OverSIP::SIP::Request instance being routed.
dst_host
The destination host. A domain or IP (String).
dst_port
The destination port (Fixnum).
dst_transport
The transport to use for sending the request (:udp, :tcp or :tls Symbols).

Examples

proxy.route request
proxy.route request, "1.2.3.4", 9060, :tcp
proxy.route request, "oversip.net"

on_canceled(&block)

NEW in 1.4.x

User programmable callback for the case in which the INVITE transaction has been canceled by the caller (by sending a CANCEL request).

Multiple callbacks can be given by calling multiple times to this method. Callbacks will be executed in the order they were set.

Example

proxy.on_canceled do
  log_info "canceled by the peer"
end

clear_on_canceled

NEW in 1.4.x

Clear all the callbacks passed to on_canceled().

drop_response

Drops the received response (so it is not forwarded upstream). This is useful for implementing SIP serial forking or for replacing a final response received from downstream.

Example

proxy.on_failure_response do |response|
  if response.status_code == 486
    log_info "user busy, forwarding to voicemail server"
    proxy.drop_response
    proxy.route request, "voicemail.example.net", 5060
  elsif response.status_code == 500
    proxy.drop_response
    request.reply 480, "Destination Not Available"
  end
end

proxy.route request