public override void AddSIPAccountAsync(SIPAccount sipAccount) { if (AddSIPAccountComplete != null) { AddSIPAccountComplete(new AddSIPAccountCompletedEventArgs(new object[] { sipAccount }, null, false, null)); } }
private void SIPAccountsDataGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { try { if (m_riaContext.SIPAccounts.Count() > 0) { DataGrid dataGrid = (DataGrid)sender; if (dataGrid.SelectedItem != null && dataGrid.CurrentColumn.Header as string != "Delete") { SIPAccount sipAccount = (SIPAccount)m_sipAccountsDataGrid.SelectedItem; if (m_selectedSIPAccount == null || m_selectedSIPAccount != sipAccount) { m_selectedSIPAccount = sipAccount; m_editControl = new SIPAccountDetailsControl(DetailsControlModesEnum.Edit, sipAccount, m_owner, null, SIPAccountUpdate, DetailsControlClosed, m_riaContext); m_sipAccountsPanel.SetDetailsElement(m_editControl); } } } } catch (Exception excp) { LogActivityMessage_External(MessageLevelsEnum.Error, "Exception showing SIP account details. " + excp.Message); m_selectedSIPAccount = null; } }
private void Update() { try { m_sipAccount.SIPPassword = m_sipAccountPassword.Text; m_sipAccount.OutDialPlanName = (m_outDialPlan.SelectedIndex != -1) ? m_outDialPlan.SelectedItem as string : null; m_sipAccount.InDialPlanName = (m_inDialPlan.SelectedIndex != -1) ? m_inDialPlan.SelectedItem as string : null; m_sipAccount.IsIncomingOnly = m_statusIncomingOnlyRadio.IsChecked.Value; m_sipAccount.SendNATKeepAlives = m_keepAlivesCheckBox.IsChecked.Value; m_sipAccount.IsUserDisabled = m_statusDisabledRadio.IsChecked.Value; m_sipAccount.NetworkID = m_sipAccountNetworkId.Text.Trim(); m_sipAccount.IPAddressACL = m_sipAccountIPAddressACL.Text.Trim(); m_sipAccount.IsSwitchboardEnabled = m_isSwitchboardEnabledCheckBox.IsChecked.Value; if (m_sipAccount.HasValidationErrors) { WriteStatusMessage(MessageLevelsEnum.Warn, m_sipAccount.ValidationErrors.First().ErrorMessage); } else { SIPAccount.Clean(m_sipAccount); WriteStatusMessage(MessageLevelsEnum.Info, "Attempting to update SIP Account " + m_sipAccount.SIPUsername + "@" + m_sipAccount.SIPDomain + " please wait..."); UpdateSIPAccount_External(m_sipAccount); } } catch (Exception excp) { WriteStatusMessage(MessageLevelsEnum.Error, "Update SIPAccount Exception. " + excp.Message); } }
private void SIPAccountAddComplete(SubmitOperation so) { if (so.HasError) { if (m_addControl != null) { m_addControl.WriteStatusMessage(MessageLevelsEnum.Error, so.Error.Message); } else { LogActivityMessage_External(MessageLevelsEnum.Error, "There was an error adding a SIP Account. " + so.Error.Message); } m_riaContext.SIPAccounts.Remove((SIPAccount)so.UserState); so.MarkErrorAsHandled(); } else { if (m_addControl != null) { SIPAccount sipAccount = (SIPAccount)so.UserState; SIPAccountsAssetViewer_Add(); m_addControl.WriteStatusMessage(MessageLevelsEnum.Info, "SIP Account was successfully created for " + sipAccount.SIPUsername + "@" + sipAccount.SIPDomain + "."); } m_sipAccountsPanel.AssetAdded(); } }
/// <summary> /// Phone line info as SIPAccount. /// </summary> /// <param name="pli">The provided phone line information.</param> /// <returns>An SIP account.</returns> public static SIPAccount AsSIPAccount(this PhoneLineInfo pli) { string domain; int port = 5060; string[] splittedDomain = pli.Domain.Split(':'); if (splittedDomain.Length > 1) { port = Int32.Parse(splittedDomain[1]); } domain = splittedDomain[0]; SIPAccount acc = new SIPAccount( pli.RegRequired, pli.DisplayName, pli.Username, pli.RegisterName, pli.Password, domain, port, pli.Proxy ); return(acc); }
/// <summary> /// 设备注册事件 /// </summary> /// <param name="sipTransaction"></param> /// <param name="sIPAccount"></param> private void _sipRegistrarCore_RPCDmsRegisterReceived(SIPTransaction sipTransaction, GB28181.App.SIPAccount sIPAccount) { try { _SIPAccount = sIPAccount; string deviceid = sipTransaction.TransactionRequestFrom.URI.User; //GB SIPTransactions Dictionary GBSIPTransactions.Remove(deviceid); GBSIPTransactions.Add(deviceid, sipTransaction); //Device Catalog Query _sipCoreMessageService.DeviceCatalogQuery(deviceid); ////query device info from db //string edit = IsDeviceExisted(deviceid) ? "updated" : "added"; ////Device Dms Register //DeviceDmsRegister(sipTransaction,"gb"); ////Device Edit Event //DeviceEditEvent(deviceid, edit); } catch (Exception ex) { logger.Error("_sipRegistrarCore_RPCDmsRegisterReceived Exception: " + ex.Message); } }
public override void DeleteSIPAccount(SIPAccount sipAccount) { if (DeleteSIPAccountComplete != null) { DeleteSIPAccountComplete(new DeleteSIPAccountCompletedEventArgs(new object[] { sipAccount }, null, false, null)); } }
/// <summary> /// Registers the SIP account to the PBX. /// Calls cannot be made while the SIP account is not registered. /// If the SIP account requires no registration, the RegisterPhoneLine() must be called too to register the SIP account to the ISoftPhone. /// </summary> public void Register(bool registrationRequired, string displayName, string userName, string authenticationId, string registerPassword, string domainHost, int domainPort) { try { // We need to handle the event, when we have an incoming call. _softphone.IncomingCall += softphone_IncomingCall; // To register to a PBX, we need to create a SIP account var account = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort); // With the SIP account and the NAT configuration, we can create a phoneline. _phoneLine = _softphone.CreatePhoneLine(account); // The phoneline has states, we need to handle the event, when it is being changed. _phoneLine.RegistrationStateChanged += phoneLine_PhoneLineStateChanged; // If our phoneline is created, we can register that. _softphone.RegisterPhoneLine(_phoneLine); } catch (Exception ex) { lastError = -100; lastErrorText = "Error during SIP registration: " + ex; } }
/// <summary> /// Registers the SIP account to the PBX. /// Calls cannot be made while the SIP account is not registered. /// If the SIP account requires no registration, the RegisterPhoneLine() must be called too to register the SIP account to the ISoftPhone. /// </summary> public void Register(bool registrationRequired, string displayName, string userName, string authenticationId, string registerPassword, string domainHost, int domainPort) { try { // To register to a PBX, we need to create a SIP account var account = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort); Console.WriteLine("\nCreating SIP account {0}", account); // With the SIP account and the NAT configuration, we can create a phoneline. phoneLine = softphone.CreatePhoneLine(account); Console.WriteLine("Phoneline created."); // The phoneline has states, we need to handle the event, when it is being changed. phoneLine.RegistrationStateChanged += phoneLine_PhoneLineStateChanged; // If our phoneline is created, we can register that. softphone.RegisterPhoneLine(phoneLine); // For further information about the calling of the ConnectMedia(), please check the implementation of this method. ConnectMedia(); } catch (Exception ex) { Console.WriteLine("Error during SIP registration: " + ex.ToString()); } }
public void Start() { try { logger.Debug("SIP Registrar daemon starting..."); // Configure the SIP transport layer. m_sipTransport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine(), false); m_sipTransport.PerformanceMonitorPrefix = SIPSorceryPerformanceMonitor.REGISTRAR_PREFIX; SIPAccount account = SipStorage.Instance.Accounts.FirstOrDefault(); var sipChannels = SIPTransportConfig.ParseSIPChannelsNode(account.LocalIP, account.LocalPort); m_sipTransport.AddSIPChannel(sipChannels); MessageCore = new SIPMessageCore(m_sipTransport, SIPConstants.SIP_SERVER_STRING); MessageCore.Initialize(SIPAuthenticateRequest_External, _platformList, _account); GB28181Catalog.Instance.MessageCore = MessageCore; m_sipTransport.SIPTransportRequestReceived += MessageCore.AddMessageRequest; m_sipTransport.SIPTransportResponseReceived += MessageCore.AddMessageResponse; Console.ForegroundColor = ConsoleColor.Green; logger.Debug("SIP Registrar successfully started."); Console.ForegroundColor = ConsoleColor.White; } catch (Exception excp) { logger.Error("Exception SIPRegistrarDaemon Start. " + excp.Message); } }
private void InitializeSoftPhone() { try { softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750); InvokeGUIThread(() => { lb_Log.Items.Add("Softphone created!"); }); softPhone.IncomingCall += new EventHandler <VoIPEventArgs <IPhoneCall> >(softPhone_inComingCall); SIPAccount sa = new SIPAccount(true, "1000", "1000", "1000", "1000", "192.168.115.103", 5060); InvokeGUIThread(() => { lb_Log.Items.Add("SIP account created!"); }); phoneLine = softPhone.CreatePhoneLine(sa); phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation; InvokeGUIThread(() => { lb_Log.Items.Add("Phoneline created."); }); softPhone.RegisterPhoneLine(phoneLine); tb_Display.Text = string.Empty; lbl_NumberToDial.Text = sa.RegisterName; inComingCall = false; reDialNumber = string.Empty; localHeld = false; ConnectMedia(); } catch (Exception ex) { InvokeGUIThread(() => { lb_Log.Items.Add("Local IP error!"); }); } }
public async Task <IActionResult> PutSIPAccount(Guid id, SIPAccount SIPAccount) { if (id != SIPAccount.ID) { return(BadRequest()); } _context.Entry(SIPAccount).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SIPAccountExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void AddNATKeepAliveJob(SIPAccount sipAccount, SIPEndPoint remoteSIPEndPoint, SIPEndPoint proxySIPEndPoint, SIPRegistrarBinding binding, int bindingExpiry) { try { lock (m_natKeepAliveJobs) { if (m_natKeepAliveJobs.ContainsKey(binding.RemoteSIPSocket)) { //logger.Debug("Updating NAT keep-alive job for binding socket " + binding.RemoteSIPSocket + "."); m_natKeepAliveJobs[binding.RemoteSIPSocket] .Update(proxySIPEndPoint, DateTime.Now.AddSeconds(bindingExpiry)); } else { //logger.Debug("Adding NAT keep-alive job for binding socket " + binding.RemoteSIPSocket + "."); m_natKeepAliveJobs.Add(binding.RemoteSIPSocket, new NATKeepAliveJob(proxySIPEndPoint, remoteSIPEndPoint, DateTime.Now.AddSeconds(bindingExpiry), sipAccount.Owner)); } } } catch (Exception natAddExcp) { Logger.Logger.Error("Exception AddNATKeepAliveJob for SIP account " + sipAccount.SIPUsername + ". ->" + natAddExcp.Message); } }
public static bool registerToSIP() { try { settingSIP settingSIP = (from p in Application.OpenForms.OfType <settingSIP>() select p).FirstOrDefault(); sipClient.sipMessageManipulator = new SIP_CustomMessageManipulator(); sipClient.softphone.SetSIPMessageManipulator(sipClient.sipMessageManipulator); /*if (sipHostName.Length > 1) // eğer hostname varsa, IP yerine hostname ile bağlan. * sipServerIp = sipHostName;*/ var account = new SIPAccount(true, sipUserName, sipUserName, sipAuth, sipPassword, sipServerIp, Int32.Parse(sipServerPort) ); sipClient.phoneLine1 = sipClient.softphone.CreatePhoneLine(account); sipClient.softphone.RegisterPhoneLine(sipClient.phoneLine1); return(true); } catch (InvalidCastException err) { MessageBox.Show(err.Message); return(false); } }
/// <summary> /// Inicializa la información de los controles que se usarán para el teléfono /// </summary> void InitializeSoftphone() { try { UsuarioLinea ln = new UsuarioLinea().ObtenerLinea(int.Parse(AUsuarioData.sIdusuario)); _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750); SIPAccount sa = new SIPAccount(true, ln.sDisplayName, ln.sUserName, ln.sRegisterName, ln.sRegisterPassword, ln.sDomainHost, ln.iDomainPort); _phoneLine = _softPhone.CreatePhoneLine(sa); _phoneLine.RegistrationStateChanged += _phoneLine_RegistrationStateChanged; _softPhone.IncomingCall += _softPhone_IncomingCall; _softPhone.RegisterPhoneLine(_phoneLine); _incomingCall = false; ConnectMedia(); } catch (Exception ex) { InvokeGUIThread(() => { txtDisplay.Text = ex.Message; }); } }
public static CallHistoryInfo ToPhoneCallInfo(this IPhoneCall call) { SIPAccount account = call.PhoneLine.SIPAccount; DialInfo caller = new DialInfo(account.DisplayName, account.UserName, account.DomainServerHost); return(new CallHistoryInfo(caller, call.DialInfo, call.IsIncoming, call.CallState, call.ReasonOfState)); }
public void InitializeSoftPhone() { try { var userAgent = "MyFirstSoftPhone-3-example"; _message = new List <string>(); _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750, userAgent); _message.Add("Softphone created!"); //InvokeGUIThread(() => { lb_Log.Items.Add("Softphone created!"); }); _softPhone.IncomingCall += softPhone_inComingCall; SIPAccount sa = new SIPAccount(true, "2001", "2001", "2001", "2001", "172.16.1.17"); _message.Add("SIP account created!"); //InvokeGUIThread(() => { lb_Log.Items.Add("SIP account created!"); }); _phoneLine = _softPhone.CreatePhoneLine(sa); _phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation; _message.Add("Phoneline created."); //InvokeGUIThread(() => { lb_Log.Items.Add("Phoneline created."); }); _softPhone.RegisterPhoneLine(_phoneLine); _registerName = sa.RegisterName; _inComingCall = false; _reDialNumber = string.Empty; //_localHeld = false; ConnectMedia(); } catch (Exception ex) { _message.Add(ex.ToString()); } }
public void Initialize(SIPAuthenticateRequestDelegate sipRequestAuthenticator, Dictionary <string, PlatformConfig> platformList, SIPAccount account) { m_registrarCore = new RegistrarCore(Transport, true, true, sipRequestAuthenticator); m_registrarCore.Start(1); foreach (var item in platformList) { string sipEndPointStr = "udp:" + item.Value.RemoteIP + ":" + item.Value.RemotePort; SIPEndPoint sipPoint = SIPEndPoint.ParseSIPEndPoint(sipEndPointStr); for (int i = 0; i < 2; i++) { CommandType cmdType = CommandType.Unknown; if (i == 0) { cmdType = CommandType.Play; } else { cmdType = CommandType.Playback; } string key = item.Key + cmdType; ISIPMonitorService monitor = new SIPMonitorCore_2011(this, item.Key, item.Value.ChannelName, sipPoint); monitor.OnSIPServiceChanged += monitor_OnSIPServiceChanged; MonitorService.Add(key, monitor); } } }
public void RegisterSipAccount(AccountModel model) { try { if (model == null) { return; } if (PhoneLine != null) { PhoneLine.RegistrationStateChanged -= phoneLine_RegistrationStateChanged; } var account = new SIPAccount(model.RegistrationRequired, model.DisplayName, model.UserName, model.RegisterName, model.Password, model.Domain, model.OutboundProxy); PhoneLine = Softphone.CreatePhoneLine(account); PhoneLine.RegistrationStateChanged += phoneLine_RegistrationStateChanged; Softphone.RegisterPhoneLine(PhoneLine); Log.Write(string.Format("Registering phone line " + model.UserName)); } catch (Exception exception) { Log.Write("Error during SIP registration: " + exception.Message); MessageBox.Show("Error during SIP registration: " + exception.Message); } }
private void InitializeSoftPhone() { try { var userAgent = "MyFirstSoftPhone-3-example"; _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750, userAgent); InvokeGUIThread(() => { lb_Log.Items.Add("Softphone created!"); }); _softPhone.IncomingCall += softPhone_inComingCall; SIPAccount sa = new SIPAccount(true, "100", "100", "100", "123456", "192.168.1.6", 5060); InvokeGUIThread(() => { lb_Log.Items.Add("SIP account created!"); }); _phoneLine = _softPhone.CreatePhoneLine(sa); _phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation; InvokeGUIThread(() => { lb_Log.Items.Add("Phoneline created."); }); _softPhone.RegisterPhoneLine(_phoneLine); tb_Display.Text = string.Empty; lbl_NumberToDial.Text = sa.RegisterName; _inComingCall = false; _reDialNumber = string.Empty; _localHeld = false; ConnectMedia(); } catch (Exception ex) { InvokeGUIThread(() => { lb_Log.Items.Add("Local IP error! " + ex); }); } }
public void UpdateSIPAccountTest() { SIPEntitiesDomainService target = new SIPEntitiesDomainService(); // TODO: Initialize to an appropriate value SIPAccount currentSIPAccount = null; // TODO: Initialize to an appropriate value target.UpdateSIPAccount(currentSIPAccount); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
private void DoSubscribe(SIPNonInviteTransaction subTx) { SIPRequest req = subTx.TransactionRequest; string user = req.Header.From.FromURI.User; string domain = req.Header.From.FromURI.HostAddress; string canonicalDomain = m_sipDomainManager.GetCanonicalDomain(domain); if (canonicalDomain == null) { Logger.LogWarning($"Subscribe Register request for {req.Header.From.FromURI.Host} rejected as no matching domain found."); SIPResponse noDomainResponse = SIPResponse.GetResponse(req, SIPResponseStatusCodesEnum.Forbidden, "Domain not serviced"); subTx.SendResponse(noDomainResponse); } else { SIPAccount sipAccount = m_sipAccountsDataLayer.GetSIPAccount(user, canonicalDomain).Result; if (sipAccount == null) { Logger.LogWarning($"SubscriberCore SIP account {user}@{canonicalDomain} does not exist."); SIPResponse forbiddenResponse = SIPResponse.GetResponse(req, SIPResponseStatusCodesEnum.Forbidden, null); subTx.SendResponse(forbiddenResponse); } else { SIPRequestAuthenticationResult authenticationResult = SIPRequestAuthenticator.AuthenticateSIPRequest(req.LocalSIPEndPoint, req.RemoteSIPEndPoint, req, sipAccount); if (!authenticationResult.Authenticated) { // 401 Response with a fresh nonce needs to be sent. SIPResponse authReqdResponse = SIPResponse.GetResponse(req, authenticationResult.ErrorResponse, null); authReqdResponse.Header.AuthenticationHeader = authenticationResult.AuthenticationRequiredHeader; subTx.SendResponse(authReqdResponse); if (authenticationResult.ErrorResponse == SIPResponseStatusCodesEnum.Forbidden) { Logger.LogWarning($"Forbidden {sipAccount.AOR} does not exist, received from {req.RemoteSIPEndPoint}, user agent {req.Header.UserAgent}."); } } else { SIPResponse okResponse = SIPResponse.GetResponse(req, SIPResponseStatusCodesEnum.Ok, null); subTx.SendResponse(okResponse); Logger.LogDebug($"Subscription request for {user}@{domain} was successful."); // Give the subscribe response time to be sent. Thread.Sleep(500); if (req.Header.Expires > 0) { SendInitialNotification(req, sipAccount); } } } } }
public SIPRegistrarCoreService(ISIPTransport sipTransport, ISipAccountStorage sipAccountStorage, IMemoCache <Camera> cameraCache, bool mangleUACContact = true, bool strictRealmHandling = true) { _sipTransport = sipTransport; m_mangleUACContact = mangleUACContact; m_strictRealmHandling = strictRealmHandling; _localSipAccount = sipAccountStorage.GetLocalSipAccout(); _needAuthentication = _localSipAccount.Authentication; _cameraCache = cameraCache; }
/// <summary> /// Creates a phone line and adds it to the collection. /// </summary> public IPhoneLine AddPhoneLine(SIPAccount account, Ozeki.Network.TransportType transportType, NatConfiguration natConfig, SRTPMode srtpMode) { var config = new PhoneLineConfiguration(account); config.TransportType = transportType; config.NatConfig = natConfig; config.SRTPMode = srtpMode; return(AddPhoneLine(config)); }
public SIPMessageDaemon( SIPAccount account, SIPAuthenticateRequestDelegate sipRequestAuthenticator, Dictionary <string, PlatformConfig> platformList) { _account = account; SIPAuthenticateRequest_External = sipRequestAuthenticator; _platformList = platformList; }
/// <summary> /// Creates a phone line and adds it to the collection. /// </summary> public IPhoneLine AddPhoneLine(SIPAccount account, Ozeki.Network.TransportType transportType, NatConfiguration natConfig, SRTPMode srtpMode) { IPhoneLine line = softPhone.CreatePhoneLine(account, natConfig, transportType, srtpMode); SubscribeToLineEvents(line); // add to collection PhoneLines.Add(line); return(line); }
/// <summary> /// 本机平台端口是否被监听 /// </summary> /// <param name="channels">sip通道</param> /// <param name="account">平台配置信息</param> /// <returns>true被监听/false未被监听</returns> private static bool PortListen(List <SIPChannel> channels, SIPAccount account) { foreach (var channel in channels) { if (channel.SIPChannelEndPoint.Port == account.LocalPort) { return(true); } } return(false); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { SIPAccount account = value as SIPAccount; if (account == null) { return(value); } return(string.Format("{0}@{1}", account.UserName, account.DomainServerHost)); }
//开始实时视频 private void BtnReal_Click(object sender, EventArgs e) { SIPAccount account = SipStorage.Instance.Accounts.FirstOrDefault(); int[] mediaPort = { account.MediaPort }; string ip = account.MediaIP.ToString(); _analyzer = new StreamAnalyzer(); _messageCore.NodeMonitorService[DevKey.ToString()].RealVideoReq(mediaPort, ip, true); //_messageCore.NodeMonitorService[DevKey.ToString()].RealVideoReq(); _messageCore.NodeMonitorService[DevKey.ToString()].OnStreamReady += Form1_OnStreamReady; }
public void Save(SIPAccount account) { if (_accounts.Any(d => d.SIPUsername == account.SIPUsername || d.SIPDomain == account.SIPDomain)) { SipAccount.Update(account); } else { SipAccount.Add(account); _accounts.Add(account); } }
ISoftPhone softphone; // softphone object #endregion Fields #region Methods public string Get(string id) { Regex regexObj = new Regex(@"[^\d]"); id2 = regexObj.Replace(id, ""); softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000); var registrationRequired = true; var userName = "******"; var displayName = "730"; var authenticationId = "730"; var registerPassword = ""; var domainHost = "192.168.60.225"; var domainPort = 5060; var account = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort); RegisterAccount(account); mediaSender = new PhoneCallAudioSender(); connector = new MediaConnector(); int count = 0; while (done == 0 && count < 120) { count++; Thread.Sleep(1000); } return message; }
/// <summary> /// Phone line info as SIPAccount. /// </summary> /// <param name="pli">The provided phone line information.</param> /// <returns>An SIP account.</returns> public static SIPAccount AsSIPAccount(this PhoneLineInfo pli) { string domain; int port = 5060; string[] splittedDomain = pli.Domain.Split(':'); if (splittedDomain.Length > 1) port = Int32.Parse(splittedDomain[1]); domain = splittedDomain[0]; SIPAccount acc = new SIPAccount( pli.RegRequired, pli.DisplayName, pli.Username, pli.RegisterName, pli.Password, domain, port, pli.Proxy ); return acc; }
public void RegisterSipAccount(AccountModel model) { try { if (model == null) return; if (PhoneLine != null) { PhoneLine.RegistrationStateChanged -= phoneLine_RegistrationStateChanged; } var account = new SIPAccount(model.RegistrationRequired, model.DisplayName, model.UserName, model.RegisterName, model.Password, model.Domain, model.OutboundProxy); PhoneLine = Softphone.CreatePhoneLine(account); PhoneLine.RegistrationStateChanged += phoneLine_RegistrationStateChanged; Softphone.RegisterPhoneLine(PhoneLine); Log.Write(string.Format("Registering phone line " + model.UserName)); } catch (Exception exception) { Log.Write("Error during SIP registration: " + exception.Message); MessageBox.Show("Error during SIP registration: " + exception.Message); } }
void RegisterAccount(SIPAccount account) { try { phoneLine = softphone.CreatePhoneLine(account); phoneLine.RegistrationStateChanged += line_RegStateChanged; softphone.RegisterPhoneLine(phoneLine); } catch (Exception ex) { message = "Error during SIP registration: " + ex; } }
/// <summary> /// Creates a phone line and adds it to the collection. /// </summary> public IPhoneLine AddPhoneLine(SIPAccount account, Ozeki.Network.TransportType transportType, NatConfiguration natConfig, SRTPMode srtpMode) { var config = new PhoneLineConfiguration(account); config.TransportType = transportType; config.NatConfig = natConfig; config.SRTPMode = srtpMode; return AddPhoneLine(config); }
/// <summary> ///It initializes a softphone object with a SIP BPX, and it is for requisiting a SIP account that is nedded for a SIP PBX service. It registers this SIP ///account to the SIP PBX through an ’IphoneLine’ object which represents the telephoneline. ///If the telephone registration is successful we have a call ready softphone. In this example the softphone can be reached by dialing the number 891. /// </summary> private void InitializeSoftPhone() { try { if (Ozeki.VoIP.SDK.Protection.LicenseManager.Instance.LicenseType != Ozeki.VoIP.SDK.Protection.LicenseType.Activated) Ozeki.VoIP.SDK.Protection.LicenseManager.Instance.SetLicense(m_OzekiLicenseId, m_OzekiLicenseKey); using (BrightPlatformEntities objDbModel = new BrightPlatformEntities(UserSession.EntityConnection)) { int? _SipAcctId = objDbModel.users.FirstOrDefault(i => i.id == UserSession.CurrentUser.UserId).sip_id; if (!_SipAcctId.HasValue) { //MessageBox.Show( // string.Format("Your account is not yet configured for calling.{0}Please contact your administrator.", Environment.NewLine), // "Bright Sales", // MessageBoxButtons.OK, // MessageBoxIcon.Information //); BrightVision.Common.UI.NotificationDialog.Error( "Bright Sales", string.Format("Your account is not yet configured for calling.{0}Please contact your administrator.", Environment.NewLine) ); return; } sip_accounts sip = objDbModel.sip_accounts.FirstOrDefault(i => i.id == _SipAcctId); if (sip != null) objDbModel.Detach(sip); if (m_UserAudioSetting == null) m_UserAudioSetting = AudioSettingUtility.GetUserAudioSetting(); m_UserMicrophone = AudioSettingUtility.GetDefaultDeviceMicrophone(); m_UserSpeaker = AudioSettingUtility.GetDefaultDeviceSpeaker(); m_UserMicrophone.Volume = (float)m_UserAudioSetting.mic_volume / 10; m_UserSpeaker.Volume = (float)m_UserAudioSetting.speaker_volume / 10; try { softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750, 5780); } catch { } this.DisableUnwantedCodec(); softPhone.IncomingCall -= new EventHandler<VoIPEventArgs<IPhoneCall>>(softPhone_IncomingCall); softPhone.IncomingCall += new EventHandler<VoIPEventArgs<IPhoneCall>>(softPhone_IncomingCall); SIPAccount acc = new SIPAccount( true, sip.display_name.Trim(), sip.username.Trim(), sip.username.Trim(), sip.password, sip.sip_url.Trim(), 5060, "" ); // var acc = new SIPAccount(true, sip.display_name, sip.username, sip.username, sip.password, sip.sip_url, 5060,""); // NatConfiguration newNatConfiguration = new NatConfiguration(NatTraversalMethod.Auto, new NatRemoteServer("stun.ozekiphone.com", "", "")); phoneLine = softPhone.CreatePhoneLine(acc, Ozeki.Network.TransportType.Udp, SRTPMode.None); phoneLine.PhoneLineStateChanged -= new EventHandler<VoIPEventArgs<PhoneLineState>>(phoneLine_PhoneLineInformation); phoneLine.PhoneLineStateChanged += new EventHandler<VoIPEventArgs<PhoneLineState>>(phoneLine_PhoneLineInformation); softPhone.RegisterPhoneLine(phoneLine); objDbModel.Dispose(); } } catch (Exception ex) { } }
/// <summary> /// Creates a phone line and adds it to the collection. /// </summary> public IPhoneLine AddPhoneLine(SIPAccount account, Ozeki.Network.TransportType transportType, NatConfiguration natConfig, SRTPMode srtpMode) { IPhoneLine line = softPhone.CreatePhoneLine(account, natConfig, transportType, srtpMode); SubscribeToLineEvents(line); // add to collection PhoneLines.Add(line); return line; }