public void Run() { _log.Info("Starting server"); try { _config = new Config("config.txt"); } catch (FileNotFoundException) { _log.Fatal("Configuration file not found"); return; } _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), _config.GetIntValue("sip.min"), _config.GetIntValue("sip.max"), _config.GetIntValue("sip.port")); _phoneLine = _softPhone.CreatePhoneLine(new SIPAccount(true, _config.GetStringValue("sip.displayname"), _config.GetStringValue("sip.username"), _config.GetStringValue("sip.username"), _config.GetStringValue("sip.password"), _config.GetStringValue("sip.host")), new NatConfiguration(_config.GetStringValue("externalip"), true)); _phoneLine.PhoneLineStateChanged += phoneLine_PhoneLineStateChanged; _softPhone.RegisterPhoneLine(_phoneLine); _softPhone.IncomingCall += softPhone_IncomingCall; // Wait 3 seconds and check if the line is registered. If not, shut down. System.Threading.Thread.Sleep(3000); if (_phoneLine.LineState != PhoneLineState.RegistrationSucceeded) { _log.Error(String.Format("Phone Line is not registered. State is {0}. Exiting.", _phoneLine.LineState.ToString())); return; } lock (_sync) System.Threading.Monitor.Wait(_sync); }
/// <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; }); } }
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!"); }); } }
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 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()); } }
/// <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 { softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750, 5700); softPhone.IncomingCall += new EventHandler<VoIPEventArgs<IPhoneCall>>(softPhone_IncomingCall); // arama geldiğinde çalışan fonksiyon. phoneLine = softPhone.CreatePhoneLine(new SIPAccount(true, "7134", "7134", "7134", "123456", "sip.kobikom.com", 5060), new NatConfiguration(NatTraversalMethod.None)); //phoneLine = softPhone.CreatePhoneLine(new SIPAccount(true, "oz875", "oz875", "oz875", "oz875", "192.168.112.100", 5060), new NatConfiguration(NatTraversalMethod.None)); phoneLine.PhoneLineStateChanged += new EventHandler<VoIPEventArgs<PhoneLineState>>(phoneLine_PhoneLineInformation); softPhone.RegisterPhoneLine(phoneLine); } catch (Exception ex) { MessageBox.Show(String.Format("You didn't give your local IP adress, so the program won't run properly.\n {0}", ex.Message), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); var sb = new StringBuilder(); sb.AppendLine("Some error happened."); sb.AppendLine(); sb.AppendLine("Exception:"); sb.AppendLine(ex.Message); sb.AppendLine(); if (ex.InnerException != null) { sb.AppendLine("Inner Exception:"); sb.AppendLine(ex.InnerException.Message); sb.AppendLine(); } sb.AppendLine("StackTrace:"); sb.AppendLine(ex.StackTrace); MessageBox.Show(sb.ToString()); } }
public OzekiLiveStream() { softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750); softPhone.IncomingCall += SoftPhone_IncomingCall; conferenceRoom = new ConferenceRoom(); conferenceRoom.StartConferencing(); }
/// <summary> /// Initializes the softphone logic /// Subscribes change events to get notifications. /// Register info event /// Incoming call event /// </summary> private void InitializeSoftPhone() { try { var displayName = txtDisplayName.Text; string userName = txtUsername.Text; string authenticationId = userName; string password = txtPassword.Text; string domain = txtDomain.Text; int port = int.Parse(txtPort.Text); var userAgent = "Snowday"; _softPhone = SoftPhoneFactory.CreateSoftPhone( SoftPhoneFactory.GetLocalIP(), 7000, 9000, userAgent); InvokeGUIThread(() => { lb_Log.Items.Add("Softphone created!"); }); _softPhone.IncomingCall += softPhone_inComingCall; SIPAccount account_S = new SIPAccount(true, displayName, userName, authenticationId, password, domain, port); InvokeGUIThread(() => { lb_Log.Items.Add("SIP account created!"); }); _phoneLine = _softPhone.CreatePhoneLine(account_S); _phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation; InvokeGUIThread(() => { lb_Log.Items.Add("Phoneline created."); }); _softPhone.RegisterPhoneLine(_phoneLine); _inComingCall = false; ConnectMedia(); } catch (Exception ex) { InvokeGUIThread(() => { lb_Log.Items.Add("Local IP error! " + ex); }); } }
public bool MakeCall(Dictionary <string, string> pingData) { _log.Info("Beginning MakeCall"); _pingData = pingData; // Ensure the specified audio file is in the manifest Assembly assembly = Assembly.GetExecutingAssembly(); string resourceName = String.Format("Netopia.VOIPTester.Client.Resources.{0}", _config.GetStringValue("tonefile")); Stream resourceStream = assembly.GetManifestResourceStream(resourceName); // Console.WriteLine(String.Join("\n", assembly.GetManifestResourceNames())); if (resourceStream == null) { _log.Fatal(String.Format("Can't find embedded audio file {0}", resourceName)); return(false); } // Create the SIP client and register to the server _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), _config.GetIntValue("sip.min"), _config.GetIntValue("sip.max"), _config.GetIntValue("sip.port")); _phoneLine = _softPhone.CreatePhoneLine(new SIPAccount(true, _config.GetStringValue("sip.displayname"), _config.GetStringValue("sip.username"), _config.GetStringValue("sip.username"), _config.GetStringValue("sip.password"), _config.GetStringValue("sip.host")), new NatConfiguration(_config.GetStringValue("externalip"), true)); _phoneLine.PhoneLineStateChanged += PhoneLineStateChanged; _wavPlayback = new WaveStreamPlayback(resourceStream); _wavPlayback.Stopped += StreamingStopped; _connector.Connect(_wavPlayback, _callSender); // Register the SIP connection Register(); // Wait 3 seconds and check if the line is registered. If not, shut down. System.Threading.Thread.Sleep(3000); if (_phoneLine.LineState != PhoneLineState.RegistrationSucceeded) { _log.Error(String.Format("Phone Line is not registered. State is {0}. Exiting.", _phoneLine.LineState.ToString())); return(false); } lock (_sync) { // Wait for the defined MAX_CALL_LENGTH Monitor.Wait(_sync, MAX_CALL_LENGTH * 1000); } _log.Info("Completed call"); return(_complete); }
/// <summary> /// Initializes the softphone logic /// Subscribes change events to get notifications. /// Register info event /// Incoming call event /// </summary> private void InitializeSoftPhone() { try { var devices = Devices.EnumerateAudioEndPoints(DataFlow.All, NAudio.CoreAudioApi.DeviceState.Active); arrayDevices = devices.ToArray(); string userAgent = "Snow"; _softPhone = SoftPhoneFactory.CreateSoftPhone( SoftPhoneFactory.GetLocalIP(), 7000, 9000, userAgent); InvokeGUIThread(() => { lb_Log.Items.Add("Softphone created!"); }); _softPhone.IncomingCall += softPhone_inComingCall; InvokeGUIThread(() => { lb_Log.Items.Add("SIP account created!"); }); _phoneLine = _softPhone.CreatePhoneLine(accountSipInfo); _phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation; InvokeGUIThread(() => { lb_Log.Items.Add("Phoneline created."); }); _softPhone.RegisterPhoneLine(_phoneLine); _inComingCall = false; ConnectMedia(); } catch (Exception ex) { InvokeGUIThread(() => { lb_Log.Items.Add("Local IP error! " + ex); }); } }
public void BeginNatDiscovery() { // determine which local address used for NAT discovery string localAddress = string.Empty; if (LocalIP == null) { var localIP = SoftPhoneFactory.GetLocalIP(); if (localIP != null) { localAddress = localIP.ToString(); } } else { localAddress = LocalIP.ToString(); } // begin NAT discovery softPhone.BeginNatDiscovery(localAddress, "stun.ozekiphone.com", Callback); }
void InitializeSoftphone() { try { _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750); SIPAccount sa = new SIPAccount(true, "1000", "1000", "1000", "1000", "192.168.115.100", 5060); _phoneLine = _softPhone.CreatePhoneLine(sa); _phoneLine.RegistrationStateChanged += _phoneLine_RegistrationStateChanged; _softPhone.IncomingCall += _softPhone_IncomingCall; _softPhone.RegisterPhoneLine(_phoneLine); _incomingCall = false; ConnectMedia(); } catch (Exception ex) { InvokeGUIThread(() => { tb_Display.Text = ex.Message; }); } }
private void InitalizeSoftPhone() { try { SoftPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5000, 10000); InvokeGUIThread(mymsg = "SoftPhoneCreated!"); SoftPhone.IncomingCall += new EventHandler <VoIPEventArgs <IPhoneCall> >(SoftPhone_inComingCall); var registrationRequired = true; var userName = "******"; var displayName = "858"; var authenticationId = "858"; var registerPassword = "******"; var domainHost = SoftPhoneFactory.GetLocalIP().ToString(); var domainPort = 5060; SIPAccount sa = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort); InvokeGUIThread(mymsg = "SIP Acc Created!!"); NatConfiguration nc = new NatConfiguration(); nc.AutoDetect = true; PhoneLineConfiguration config = new PhoneLineConfiguration(sa); config.NatConfig = nc; PhoneLine = SoftPhone.CreatePhoneLine(config); PhoneLine.RegistrationStateChanged += PhoneLine_PhoneLineInfo; InvokeGUIThread(mymsg = "PhoneLine Created!!"); SoftPhone.RegisterPhoneLine(PhoneLine); ConnectMedia(); } catch (Exception ex) { InvokeGUIThread(mymsg = ("Unknown Error: " + ex)); } }
public OzekiGroupCall() { softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750); softPhone.IncomingCall += SoftPhone_IncomingCall; }