public SIPB2BUserAgentCore( SIPTransport sipTransport, IDbContextFactory <SIPAssetsDbContext> dbContextFactory, SIPDialPlanManager sipDialPlan, SIPDomainManager sipDomainManager) { if (sipTransport == null) { throw new ArgumentNullException(nameof(sipTransport)); } _sipTransport = sipTransport; _sipCallManager = new SIPCallManager(_sipTransport, null, dbContextFactory); _sipdialPlan = sipDialPlan; _sipDomainManager = sipDomainManager; _sipAccountDataLayer = new SIPAccountDataLayer(dbContextFactory); }
public SIPHostedService( ILogger <SIPHostedService> logger, IConfiguration config, IDbContextFactory <SIPAssetsDbContext> dbContextFactory, X509Certificate2 tlsCertificate, SIPDialPlanManager sipDialPlanManager) { _logger = logger; _config = config; _tlsCertificate = tlsCertificate; _sipDialPlanManager = sipDialPlanManager; _sipTransport = new SIPTransport(); // Not using the default trace logs from SIP transport as we don't want to // log requests from banned addresses. EnableTraceLogs(); _sipDomainManager = new SIPDomainManager(dbContextFactory); _sipDomainManager.Load().Wait(); _bindingsManager = new SIPRegistrarBindingsManager(new SIPRegistrarBindingDataLayer(dbContextFactory), MAX_REGISTRAR_BINDINGS); _registrarCore = new RegistrarCore(_sipTransport, _bindingsManager, dbContextFactory, _sipDomainManager); _b2bUserAgentCore = new SIPB2BUserAgentCore(_sipTransport, dbContextFactory, _sipDialPlanManager, _sipDomainManager); _sipCallManager = new SIPCallManager(_sipTransport, null, dbContextFactory); _cdrDataLayer = new CDRDataLayer(dbContextFactory); _subscriberCore = new SIPSubscriberCore(_sipTransport, dbContextFactory, _sipDomainManager); _sipFail2Ban = new SIPFail2Ban(_sipTransport); _registrarCore.OnRegisterFailure += _sipFail2Ban.RegistrationFailure; _b2bUserAgentCore.OnAcceptCallFailure += _sipFail2Ban.AcceptCallFailure; SIPCDR.CDRCreated += _cdrDataLayer.Add; SIPCDR.CDRAnswered += _cdrDataLayer.Update; SIPCDR.CDRUpdated += _cdrDataLayer.Update; SIPCDR.CDRHungup += _cdrDataLayer.Update; }