public void InitSip() { #region Создаем и настраиваем SIP-агента if (_sipAgent == null) { _sipAgent = new UserAgent(); _sipAgent.OnConnected += OnConnected; _sipAgent.OnRegistered += RegisterSIP; _sipAgent.OnIncomingCall += IncomingCall; _sipAgent.OnTerminated += TerminateCall; _sipAgent.OnRegistrationFailed += SIPRegError; _sipAgent.OnUnregistered += SipAgentOnUnregistered; _sipAgent.AddTransport(1, 5060); var mediaPort = _sipAgent.FindPort(10000, 20000, 2, 1); _sipAgent.Startup(mediaPort, 1, "", ""); } try { _sipAgent.Registrator.Register(_serverIP, _sipUser, _sipSecret, _sipUser); /* * object names = null; * object ids = null; * _sipAgent.VoiceSettings.GetPlayers(out names, out ids); * var playersId = ids as int[]; * * _sipAgent.VoiceSettings.PlayerDevice = playersId[0]; * _sipAgent.VoiceSettings.GetRecorders(out names, out ids); * var recordsId = ids as int[]; * * _sipAgent.VoiceSettings.RecorderDevice = recordsId[0]; */ } catch (Exception ex) { MessageBox.Show("Произошла ошибка при подключении к АТС!\r\n" + "Для использования звонков необходимо перезагрузить приложение!\r\n" + ex.Message, "Ошибка"); } #endregion }