当前位置: 首页>>代码示例>>Python>>正文


Python UA.disconnect方法代码示例

本文整理汇总了Python中sippy.UA.UA.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python UA.disconnect方法的具体用法?Python UA.disconnect怎么用?Python UA.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sippy.UA.UA的用法示例。


在下文中一共展示了UA.disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CallController

# 需要导入模块: from sippy.UA import UA [as 别名]
# 或者: from sippy.UA.UA import disconnect [as 别名]

#.........这里部分代码省略.........
            nh_address, same_af = oroute.getNHAddr(self.source)
        if not oroute.forward_on_fail and self.global_config['acct_enable']:
            self.acctO = RadiusAccounting(self.global_config, 'originate', \
              send_start = self.global_config['start_acct_enable'], lperiod = \
              self.global_config.getdefault('alive_acct_int', None))
            self.acctO.ms_precision = self.global_config.getdefault('precise_acct', False)
            self.acctO.setParams(oroute.params.get('bill-to', self.username), oroute.params.get('bill-cli', oroute.cli), \
              oroute.params.get('bill-cld', cld), self.cGUID, self.cId, host)
        else:
            self.acctO = None
        self.acctA.credit_time = oroute.credit_time
        conn_handlers = [self.oConn]
        disc_handlers = []
        if not oroute.forward_on_fail and self.global_config['acct_enable']:
            disc_handlers.append(self.acctO.disc)
        self.uaO = UA(self.global_config, self.recvEvent, oroute.user, oroute.passw, nh_address, oroute.credit_time, tuple(conn_handlers), \
          tuple(disc_handlers), tuple(disc_handlers), dead_cbs = (self.oDead,), expire_time = oroute.expires, \
          no_progress_time = oroute.no_progress_expires, extra_headers = oroute.extra_headers)
        self.uaO.local_ua = self.global_config['_uaname']
        if self.source != oroute.params.get('outbound_proxy', None):
            self.uaO.outbound_proxy = oroute.params.get('outbound_proxy', None)
        if self.rtp_proxy_session != None and oroute.params.get('rtpp', True):
            self.uaO.on_local_sdp_change = self.rtp_proxy_session.on_caller_sdp_change
            self.uaO.on_remote_sdp_change = self.rtp_proxy_session.on_callee_sdp_change
            self.rtp_proxy_session.caller.raddress = nh_address
            if body != None:
                body = body.getCopy()
            self.proxied = True
        self.uaO.kaInterval = self.global_config['keepalive_orig']
        if 'group_timeout' in oroute.params:
            timeout, skipto = oroute.params['group_timeout']
            Timeout(self.group_expires, timeout, 1, skipto)
        if self.global_config.getdefault('hide_call_id', False):
            cId = SipCallId(md5(str(cId).encode()).hexdigest() + ('-b2b_%d' % oroute.rnum))
        else:
            cId += '-b2b_%d' % oroute.rnum
        event = CCEventTry((cId, cGUID, oroute.cli, cld, body, auth, \
          oroute.params.get('caller_name', self.caller_name)))
        if self.eTry.max_forwards != None:
            event.max_forwards = self.eTry.max_forwards - 1
            if event.max_forwards <= 0:
                self.uaA.recvEvent(CCEventFail((483, 'Too Many Hops')))
                self.state = CCStateDead
                return
        event.reason = self.eTry.reason
        self.uaO.recvEvent(event)

    def disconnect(self, rtime = None):
        self.uaA.disconnect(rtime = rtime)

    def oConn(self, ua, rtime, origin):
        if self.acctO != None:
            self.acctO.conn(ua, rtime, origin)

    def aConn(self, ua, rtime, origin):
        self.state = CCStateConnected
        self.acctA.conn(ua, rtime, origin)

    def aDisc(self, ua, rtime, origin, result = 0):
        if self.state == CCStateWaitRoute and self.auth_proc != None:
            self.auth_proc.cancel()
            self.auth_proc = None
        if self.uaO != None and self.state != CCStateDead:
            self.state = CCStateDisconnecting
        else:
            self.state = CCStateDead
        if self.acctA != None:
            self.acctA.disc(ua, rtime, origin, result)
        self.rtp_proxy_session = None

    def aDead(self, ua):
        if (self.uaO == None or isinstance(self.uaO.state, UaStateDead)):
            if self.global_config['_cmap'].debug_mode:
                print('garbadge collecting', self)
            self.acctA = None
            self.acctO = None
            self.global_config['_cmap'].ccmap.remove(self)

    def oDead(self, ua):
        if ua == self.uaO and isinstance(self.uaA.state, UaStateDead):
            if self.global_config['_cmap'].debug_mode:
                print('garbadge collecting', self)
            self.acctA = None
            self.acctO = None
            self.global_config['_cmap'].ccmap.remove(self)

    def group_expires(self, skipto):
        if self.state != CCStateARComplete or len(self.routes) == 0 or self.routes[0][0] > skipto or \
          (not isinstance(self.uaA.state, UasStateTrying) and not isinstance(self.uaA.state, UasStateRinging)):
            return
        # When the last group in the list has timeouted don't disconnect
        # the current attempt forcefully. Instead, make sure that if the
        # current originate call leg fails no more routes will be
        # processed.
        if skipto == self.routes[-1][0] + 1:
            self.routes = []
            return
        while self.routes[0][0] != skipto:
            self.routes.pop(0)
        self.uaO.disconnect()
开发者ID:sippy,项目名称:b2bua,代码行数:104,代码来源:b2bua_radius.py

示例2: CallController

# 需要导入模块: from sippy.UA import UA [as 别名]
# 或者: from sippy.UA.UA import disconnect [as 别名]

#.........这里部分代码省略.........
                else:
                    port = SipConf.default_port
            else:
                # IPv4
                host = host.split(':', 1)
                if len(host) > 1:
                    port = int(host[1])
                else:
                    port = SipConf.default_port
                host = host[0]
        if not forward_on_fail and self.global_config['acct_enable']:
            self.acctO = RadiusAccounting(self.global_config, 'originate', \
              send_start = self.global_config['start_acct_enable'], lperiod = \
              self.global_config.getdefault('alive_acct_int', None))
            self.acctO.ms_precision = self.global_config.getdefault('precise_acct', False)
            self.acctO.setParams(parameters.get('bill-to', self.username), parameters.get('bill-cli', cli), \
              parameters.get('bill-cld', cld), self.cGUID, self.cId, host)
        else:
            self.acctO = None
        self.acctA.credit_time = credit_time
        conn_handlers = [self.oConn]
        disc_handlers = []
        if not forward_on_fail and self.global_config['acct_enable']:
            disc_handlers.append(self.acctO.disc)
        self.uaO = UA(self.global_config, self.recvEvent, user, passw, (host, port), credit_time, tuple(conn_handlers), \
          tuple(disc_handlers), tuple(disc_handlers), dead_cbs = (self.oDead,), expire_time = expires, \
          no_progress_time = no_progress_expires, extra_headers = parameters.get('extra_headers', None))
        if self.rtp_proxy_session != None and parameters.get('rtpp', True):
            self.uaO.on_local_sdp_change = self.rtp_proxy_session.on_caller_sdp_change
            self.uaO.on_remote_sdp_change = self.rtp_proxy_session.on_callee_sdp_change
            self.rtp_proxy_session.caller_raddress = (host, port)
            body = body.getCopy()
            body.content += 'a=nortpproxy:yes\r\n'
            self.proxied = True
        self.uaO.kaInterval = self.global_config['keepalive_orig']
        if parameters.has_key('group_timeout'):
            timeout, skipto = parameters['group_timeout']
            Timeout(self.group_expires, timeout, 1, skipto)
        if self.global_config.getdefault('hide_call_id', False):
            cId = SipCallId(md5(str(cId)).hexdigest() + ('-b2b_%d' % rnum))
        else:
            cId += '-b2b_%d' % rnum
        event = CCEventTry((cId, cGUID, cli, cld, body, auth, \
          parameters.get('caller_name', self.caller_name)))
        event.reason = self.eTry.reason
        self.uaO.recvEvent(event)

    def disconnect(self, rtime = None):
        self.uaA.disconnect(rtime = rtime)

    def oConn(self, ua, rtime, origin):
        if self.acctO != None:
            self.acctO.conn(ua, rtime, origin)

    def aConn(self, ua, rtime, origin):
        self.state = CCStateConnected
        self.acctA.conn(ua, rtime, origin)

    def aDisc(self, ua, rtime, origin, result = 0):
        if self.state == CCStateWaitRoute and self.auth_proc != None:
            self.auth_proc.cancel()
            self.auth_proc = None
        if self.uaO != None and self.state != CCStateDead:
            self.state = CCStateDisconnecting
        else:
            self.state = CCStateDead
        if self.acctA != None:
            self.acctA.disc(ua, rtime, origin, result)
        self.rtp_proxy_session = None

    def aDead(self, ua):
        if (self.uaO == None or isinstance(self.uaO.state, UaStateDead)):
            if self.global_config['_cmap'].debug_mode:
                print 'garbadge collecting', self
            self.acctA = None
            self.acctO = None
            self.global_config['_cmap'].ccmap.remove(self)

    def oDead(self, ua):
        if ua == self.uaO and isinstance(self.uaA.state, UaStateDead):
            if self.global_config['_cmap'].debug_mode:
                print 'garbadge collecting', self
            self.acctA = None
            self.acctO = None
            self.global_config['_cmap'].ccmap.remove(self)

    def group_expires(self, skipto):
        if self.state != CCStateARComplete or len(self.routes) == 0 or self.routes[0][0] > skipto or \
          (not isinstance(self.uaA.state, UasStateTrying) and not isinstance(self.uaA.state, UasStateRinging)):
            return
        # When the last group in the list has timeouted don't disconnect
        # the current attempt forcefully. Instead, make sure that if the
        # current originate call leg fails no more routes will be
        # processed.
        if skipto == self.routes[-1][0] + 1:
            self.routes = []
            return
        while self.routes[0][0] != skipto:
            self.routes.pop(0)
        self.uaO.disconnect()
开发者ID:DarthRa,项目名称:pulsar,代码行数:104,代码来源:b2bua_radius.py

示例3: CallController

# 需要导入模块: from sippy.UA import UA [as 别名]
# 或者: from sippy.UA.UA import disconnect [as 别名]

#.........这里部分代码省略.........
            if len(host) > 1:
                port = int(host[1])
            else:
                port = SipConf.default_port
            host = host[0]
        disc_cbs = []
        if not forward_on_fail and self.global_config['acct_enable']:
            self.acctO = RadiusAccounting(self.global_config, 'originate', send_start = self.global_config['start_acct_enable'])
            self.acctO.setParams(parameters.get('bill-to', self.username), parameters.get('bill-cli', cli), \
              parameters.get('bill-cld', cld), self.cGUID, self.cId, host, credit_time)
            print 'adding acct stop cb'
            disc_cbs.append(self.acctO.disc)
        else:
            self.acctO = None
        self.acctA.credit_time = credit_time
        ua = UA(self.global_config, self.recvEvent, user, passw, (host, port), credit_time, \
          (conn_cbs,), tuple(disc_cbs), tuple(disc_cbs), dead_cbs = (self.oDead,), \
          expire_time = expires, no_progress_time = no_progress_expires, \
          extra_headers = parameters.get('extra_headers', None))
        if self.rtp_proxy_session and parameters.get('rtpp', True):
            ua.on_local_sdp_change = self.rtp_proxy_session.on_caller_sdp_change
            ua.on_remote_sdp_change = self.rtp_proxy_session.on_callee_sdp_change
            body = body.getCopy()
            body.content += 'a=nortpproxy:yes\r\n'
            self.proxied = True
        ua.kaInterval = self.global_config['ka_orig']
        if parameters.has_key('group_timeout'):
            timeout, skipto = parameters['group_timeout']
            Timeout(self.group_expires, timeout, 1, skipto)
        ua.recvEvent(CCEventTry((cId + '-b2b_%d' % rnum, cGUID, cli, cld, body, auth, \
          parameters.get('caller_name', self.caller_name))))
        return ua

    def disconnect(self, rtime = None):
        self.uaA.disconnect(rtime = rtime)

    def oConn(self, ua, rtime, origin):
        print 'oConn(): self.state:', self.state, ', self.uaA.state:', self.uaA.state
#        traceback.print_stack(file = sys.stdout)
        if self.acctO:
            self.acctO.conn(ua, rtime, origin)

    def oConnA(self, ua, rtime, origin):
        print 'oConnA(): self.state:', self.state, ', self.uaA.state:', self.uaA.state
#        traceback.print_stack(file = sys.stdout)
        # make call.
        # The right phone answered.
        # A re-INVITE should be sent to the left phone.
        if self.acctO:
            self.acctO.conn(ua, rtime, origin)
        if not self.global_config.has_key('rtp_proxy_clients'):
            self.state = CCStateUpdatingA
            body = self.uaO.rSDP #TODO: a get method()?
            event = CCEventUpdate(body)
            self.uaO.delayed_remote_sdp_update(event, body)
        else:
            self.state = CCStateConnected

    def aConn(self, ua, rtime, origin):
        print 'aConn(): self.state:', self.state
#        traceback.print_stack(file = sys.stdout)
        self.state = CCStateConnected
        self.acctA.conn(ua, rtime, origin)

    def aConnA(self, ua, rtime, origin):
        print 'aConnA(): self.state:', self.state, ', self.uaA.state:', self.uaA.state
开发者ID:gtkiller,项目名称:b2bua,代码行数:70,代码来源:b2bua_radius.py


注:本文中的sippy.UA.UA.disconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。