使用Sipek Voip SDK接听电话

时间:2011-08-18 18:12:31

标签: c# voip

我一直在使用Sipek Voip SDK,但我无法接听电话。

在线教程不太有用,我想知道这里是否有人使用过它?我可以注册和拨打电话,但我不知道如何处理此时接听电话。我将在下面粘贴我的代码。谢谢!

这是我的主要类,我保留了回调接口。

public partial class MainWindow
{
        #region Properties
        // Get call manager instance
        CCallManager CallManager
        {
            get { return CCallManager.Instance; }
        }

        private PhoneConfig _config = new PhoneConfig();
        internal PhoneConfig Config
        {
            get { return _config; }
        }

        private IStateMachine _call = null;

        #endregion


        #region Constructor
        public MainWindow()
        {
            InitializeComponent();

            // register callbacks
            CallManager.CallStateRefresh += new DCallStateRefresh(CallManager_CallStateRefresh);
            pjsipRegistrar.Instance.AccountStateChanged += new Sipek.Common.DAccountStateChanged(Instance_AccountStateChanged);

            // Inject VoIP stack engine to CallManager
            CallManager.StackProxy = pjsipStackProxy.Instance;

            // Inject configuration settings SipekSdk
            CallManager.Config = Config;
            pjsipStackProxy.Instance.Config = Config;
            pjsipRegistrar.Instance.Config = Config;

            // Initialize
            CallManager.Initialize();
            // register accounts...
            pjsipRegistrar.Instance.registerAccounts();
        }
        #endregion

        #region Callbacks
        void Instance_AccountStateChanged(int accountId, int accState)
        {

            this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart)delegate
           {
               OnRegistrationUpdate(accountId, accState);
           });
        }

        void CallManager_CallNotification(int sessionId)
        {

        }
        void CallManager_CallStateRefresh(int sessionId)
        {
            this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart)delegate
            {
                OnStateUpdate(sessionId);
            });

        }
        #endregion

       public void OnRegistrationUpdate(int accountId, int accState)
        {
            authenticationStatus_Text.Text = accState.ToString(); 
        }

        public void OnStateUpdate(int sessionId)
       {
           callStatus_Text.Text = CallManager.getCall(sessionId).StateId.ToString();
       }

        private void release_Button_Click(object sender, RoutedEventArgs e)
        {
            dial_Text.Clear();
            CallManager.onUserRelease(_call.Session);
        }

        private void dial_Button_Click(object sender, RoutedEventArgs e)
        {
            _call = CallManager.createOutboundCall(dial_Text.Text);
        }
}

1 个答案:

答案 0 :(得分:0)

解决了我自己的问题。我使用的旧版本的dll似乎不支持来电回拨。