/// <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) { } }