Pjsip:用户注册多线程实例

该博客展示了如何使用Python的pjsua库在多线程环境中进行SIP用户注册。通过创建线程并使用互斥锁来确保线程安全,实现了对多个账号的并发注册尝试。每个线程负责一个用户的注册过程,并通过回调函数获取注册状态。
摘要由CSDN通过智能技术生成
# -*- coding: cp936 -*-
import pjsua as pj
import threading,time
import sys


def log_cb(level, str, len):
    print str,


class TestAccountCallback(pj.AccountCallback):
    iRegStatus = 0


    def __init__(self, account=None):
        pj.AccountCallback.__init__(self, account)
        self.iRegStatus = 0
        
    def on_reg_state(self):
        self.iRegStatus = self.account.info().reg_status
        


class SipRegister(threading.Thread):
    def __init__(self,lib,Domain,UserName,UserPsw):
        threading.Thread.__init__(self)
        self.lib = lib
        self.Domain = Domain
        self.UserName = UserName
        self.UserPsw = UserPsw
        self.Acc = None
        self.Acc_cb = None
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值