Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 7-Oct-12 0:13am
v4
Comments
R. Giskard Reventlov 24-Feb-11 6:57am    
Is there a question in there, somewhere?
kerzo 24-Feb-11 7:04am    
When i make a call to the asterisk server caller id return = null
kerzo 24-Feb-11 7:09am    
I need to get in coming call details..

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.

VB
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


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.
 
Share this answer
 
Comments
kerzo 24-Feb-11 7:41am    
My source code come from that link a lot of info but still i can't get any data from asterisk server.there something missing i just can't figure it out ,yet..
Espen Harlinn 25-Feb-11 11:24am    
Good point - refactoring may aid his understanding :)
Yusuf 25-Feb-11 12:04pm    
I hope so, but he seems to be a bit lost, see his comment above.
Espen Harlinn 25-Feb-11 17:38pm    
I saw, anyway good work Yusuf!
VB
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);
		}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900