Get finished call event

Oct 4, 2013 at 12:54 PM
I'm new at Asterisk, and so far i've succeeded on getting a call answered, but I can't get an event when the call is finished.

So far, this is what I have
manager = new ManagerConnection(ip, port, user, password);
manager.NewState += new NewStateEventHandler(manager_Events);
manager.Login();

...

void manager_Events(object sender, ManagerEvent e)
{
    NewStateEvent info = (NewStateEvent)e;

    //Finished call
    if (info.ChannelState == "0")
        MessageBox.Show(info.CallerIdName + " finished a call with " + e.Attributes["connectedlinename"]);
    //Answered call
    if (info.ChannelState == "6")
        MessageBox.Show(info.CallerIdName + " picked up a call " + e.Attributes["connectedlinename"]);
    else
        MessageBox.Show(info.ChannelStateDesc);
}
I've already checked, and no sort of event arrives at the NewState event when the call ends.

Any suggestions?
Oct 4, 2013 at 2:52 PM
A few options,
  1. You should get a "Down" NewState if i remember correctly, if you're not - unsure why. But that doesn't mean the call hungup.
  2. HangupEvent - This will be raised when the call hangs-up.
Hope that helps.
Feb 12, 2014 at 8:37 PM
Can anybody help me? I need to translate these two sentences to Visual Basic .net
manager.NewState += new NewStateEventHandler(manager_Events);
void manager_Events(object sender, ManagerEvent e)
Thanks in advance.
Feb 16, 2014 at 7:39 PM
Para quien le pueda interesar me contesto a mi mismo:
C#
        manager.NewState += new NewStateEventHandler(manager_Events);
visual basic .net
        AddHandler asteriskManager.NewState, New AsterNET.Manager.NewStateEventHandler(Address Of manager_Events)


C#
        void manager_Events(object sender, ManagerEvent e)
visual basic .net
        Public Sub manager_Events(ByVal sender As Object, ByVal e As AsterNET.Manager.Event.NewStateEvent)