asterisk.net(如何获取来电信息?)到目前为止,我的代码... [英] asterisk.net ( How to get incoming call info ?) my code so far...

查看:89
本文介绍了asterisk.net(如何获取来电信息?)到目前为止,我的代码...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我拨打星号服务器呼叫者ID时,返回= null

我需要输入来电详细信息.

When I make a call to the asterisk server caller id return = null

I need to get in coming call details.

Imports Asterisk.NET.Manager
Imports Asterisk.NET.Manager.Event
Imports Asterisk.NET.FastAGI.Command
Imports Asterisk.NET.FastAGI
Imports Asterisk.NET.IO
Imports System.Text

Public Class Form1

    Dim manager1 As ManagerConnection
    Dim manager2 As StatusEvent
    Dim manager3 As AgentCalledEvent
    Dim manager4 As GetDataCommand
    Dim manager5 As AGIRequest
    Dim manager6 As NewCallerIdEvent
    Dim manager7 As DialEvent
    Dim manager8 As Originate
    Dim manager9 As ManagerReader
    Dim manager10 As ResponseEvent
    Dim manager11 As SocketConnection
    Dim manager12 As CdrEvent
    Dim compdata As ASCIIEncoding


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click


        manager1 = New ManagerConnection("192.168.1.3", 5038, "test", "test")


        manager1.Login()

      

        MsgBox("o.k")

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        manager6 = New NewCallerIdEvent(manager1)
       
        MsgBox(manager6.CallerId)


    End Sub

推荐答案

您是否检查过该星号信息页面? http://www.voip-info.org/wiki/view/Asterisk+manager+API [ ^ ]它有很多信息.

但是,您的代码有些麻烦.

Did you check this Asterisk info page? http://www.voip-info.org/wiki/view/Asterisk+manager+API[^] It has a wealth of info.

But, there is somewhat troubling in your code.

Dim manager1 As ManagerConnection
    Dim manager2 As StatusEvent
    Dim manager3 As AgentCalledEvent
    Dim manager4 As GetDataCommand
    Dim manager5 As AGIRequest
    Dim manager6 As NewCallerIdEvent
    Dim manager7 As DialEvent
    Dim manager8 As Originate
    Dim manager9 As ManagerReader
    Dim manager10 As ResponseEvent
    Dim manager11 As SocketConnection
    Dim manager12 As CdrEvent
    Dim compdata As ASCIIEncoding



您能为您的变量想个更好的名字吗?为什么每一个都必须为manager.当然,即使您将它们命名为fooBar,编译器也不会在意,但是有些人会.我相信这会在您继续开发解决方案时咬住您的后方.



Could you not think better names to your variables? Why does every single one of them need to be manager. Of course the compiler does not care even if you name them fooBar but some one will. I am sure this will bite you on the rear as you continue developing your solution.


public partial class FormMain : Form
	{
        ManagerConnection manager1 = new ManagerConnection();
        NewCallerIdEvent manager6;
		public FormMain()
		{
			InitializeComponent();
		}

		private ManagerConnection manager = null;
		private void btnConnect_Click(object sender, EventArgs e)
		{
			string address = this.tbAddress.Text;
			int port = int.Parse(this.tbPort.Text);
			string user = this.tbUser.Text;
			string password = this.tbPassword.Text;

			btnConnect.Enabled = false;
			manager = new ManagerConnection(address, port, user, password);
			manager.UnhandledEvent += new ManagerEventHandler(manager_Events);

            // +++ Only to debug purpose
            manager.FireAllEvents = true;
            // manager.DefaultEventTimeout = 0;
            // manager.DefaultResponseTimeout = 0;
            manager.PingInterval = 0;
			try
			{
				// Uncomment next 2 line comments to Disable timeout (debug mode)
			// manager.DefaultResponseTimeout = 0;
		// manager.DefaultEventTimeout = 0;
				manager.Login();
			}
			catch(Exception ex)
			{
				MessageBox.Show("Error connect\n" + ex.Message);
				manager.Logoff();
			//	this.Close();
			}
			btnDisconnect.Enabled = true;
		}

		void manager_Events(object sender, ManagerEvent e)
		{
			Debug.WriteLine("Event : " + e.GetType().Name);
		}


这篇关于asterisk.net(如何获取来电信息?)到目前为止,我的代码...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆