Select Page
This entry has been published on 2015-10-23 and may be out of date.

Last Updated on 2015-10-23.

Unfortunately, there is not much documentation regarding the AsterNet library, so the code snippet below might help someone who simply wants to abort an incoming or outgoing call, e.g. via a C# .Net button.

Basically this is quite simple, you only have to remember the current channel ID; it is not enough to create a HangupAction with your SIP number as parameter.

In your constructor method, create “global” ManagerConnection instance. Example:

private ManagerConnection manager = null;
        private void Connect()
        {            
            manager = new ManagerConnection(Properties.Settings.Default.host, Properties.Settings.Default.port, Properties.Settings.Default.user, Properties.Settings.Default.pw);

            manager.NewChannel += manager_NewChannel;

            manager.PingInterval = 0;
                                  
            try
            {
                manager.Login();
            }
            catch (Exception ex)
            {
                manager.Logoff();
            }
        }

 

Handle manager.NewChannel event (replace “userrow.number” with the personal number of the current user, you might get it via Active Directory or your preferred user database):

private String curChannel;
void manager_NewChannel(object sender, AsterNET.Manager.Event.NewChannelEvent e)
        {
            if (e.CallerIdNum != userrow.number)
                return;

            curChannel = e.Channel;
            
        }

Create a button and handle the Click event:

private void buttonDrop_Click(object sender, EventArgs e)
        {            
            if (curChannel == null)
                return;
            
            HangupAction action = new HangupAction(curChannel);
            manager.SendAction(action);
        }