Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Commit

Permalink
Add methods clean_on_xxxxxx() and clean_callbacks() to clean the exis…
Browse files Browse the repository at this point in the history
…ting callbacks in OverSIP::SIP::Proxy and OverSIP::SIP::Uac.
  • Loading branch information
ibc committed Feb 4, 2013
1 parent 4b7c47f commit 774de3b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
40 changes: 39 additions & 1 deletion lib/oversip/sip/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Client

include ::OverSIP::Logger

attr_reader :current_target
attr_reader :request, :current_target

def initialize proxy_profile=:default_proxy
unless (@conf = ::OverSIP.proxies[proxy_profile.to_sym])
Expand Down Expand Up @@ -48,6 +48,44 @@ def on_target &block
@on_target_cbs << block
end

def clean_on_provisional_response
@on_provisional_response_cbs.clear
end

def clean_on_success_response
@on_success_response_cbs.clear
end

def clean_on_failure_response
@on_failure_response_cbs.clear
end

def clean_on_canceled
@on_canceled_cbs.clear
end

def clean_on_invite_timeout
@on_invite_timeout_cbs.clear
end

def clean_on_error
@on_error_cbs.clear
end

def clean_on_target
@on_target_cbs.clear
end

def clean_callbacks
@on_provisional_response_cbs.clear
@on_success_response_cbs.clear
@on_failure_response_cbs.clear
@on_canceled_cbs.clear
@on_invite_timeout_cbs.clear
@on_error_cbs.clear
@on_target_cbs.clear
end

# By calling this method the request routing is aborted, no more DNS targets are tryed,
# a local 403 response is generated and on_error() callback is called with status 403.
def abort_routing
Expand Down
1 change: 0 additions & 1 deletion lib/oversip/sip/uac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module OverSIP::SIP

class Uac < Client


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"
Expand Down

0 comments on commit 774de3b

Please sign in to comment.