Hi
I'm trying to set up some tests using pjsua2 and pytest. However I
encountered some problems with EndPoints and Accounts. I took the
standard pjsua2 Python demo
(https://www.pjsip.org/docs/book-latest/html/intro_pjsua2.html#using-in-python-application)
and tried to make some structure of it.
The example below works fine. However if I make the created EndPoint
object global by removing the "#", then the "onRegState" callback is not
called.
Why?
My problem is that if I try to use the same EndPoint for two tests with
two different accounts, then my account classes does not work.
import time
import pjsua2 as pj
from pjsua2 import Account
class myAccount(Account):
def onRegState(self, prm):
print
("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX***OnRegState:
" + prm.reason)
def _EndPoint():
ep_cfg = pj.EpConfig()
ep_cfg.uaConfig.threadCnt = 0
# global ep
ep = pj.Endpoint()
ep.libCreate()
ep.libInit(ep_cfg)
# Create SIP transport. Error handling sample is shown
sipTpConfig = pj.TransportConfig();
sipTpConfig.port = 5060;
ep.transportCreate(pj.PJSIP_TRANSPORT_UDP, sipTpConfig);
# Start the library
ep.libStart();
return ep
def account():
acfg = pj.AccountConfig();
acfg.idUri = "sip:test@pjsip.org";
acfg.regConfig.registrarUri = "sip:pjsip.org";
acfg.idUri = "sip:u1@192.168.2.9:5069";
acfg.regConfig.registrarUri = "sip:192.168.2.9:5069";
cred = pj.AuthCredInfo("digest", "*", "test", 0, "pwtest");
acfg.sipConfig.authCreds.append( cred );
# Create the account
acc = myAccount();
acc.create(acfg);
return acc
def pjsua2_test():
e = _EndPoint()
a = account()
time.sleep(10);
return
--
-------------------- Med Liberalistiske Hilsner ----------------------
Civilingeniør, Kjeld Flarup - Mit sind er mere åbent end min tegnebog
Sofienlundvej 6B, 7560 Hjerm, Tlf: 40 29 41 49
Den ikke akademiske hjemmeside for liberalismen - www.liberalismen.dk