Click here to Skip to main content
13,351,682 members (65,502 online)
Rate this:
 
Please Sign up or sign in to vote.
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 24-Feb-11 1:55am
kerzo344
Updated 7-Oct-12 1:13am
Joan M92.3K
v4
Comments
digital man 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..
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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


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.
  Permalink  
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!
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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);
		}
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.180111.1 | Last Updated 7 Oct 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100