Building the "Hello AMIgo World" demo application

Hello AMIgo World

This section explains how to build the simple "Hello AMIgo World" application within MS Visual Studio.

Note

The source code for this example can be found in the Examples\Example1 directory

Caution

If you build this example from the given source code, you will need to change the reference to the AMIgo dll. Click on the project reference directory and delete the reference to AMIgo.dll and then click on Browse and select the AMIgo.dll file from the installation directory.

  • Create a new Windows Form Application in the .NET language of your choice(File | New | Project | C# / VB / C++ | Windows) and name it as you like.
  • Add a reference to the AMIgo.dll assembly. (Right click in the Solution Explorer and select 'Add Reference')
  • Open the AMIgo tab in the Toolbox Windows and drag an AMI_Client object on your project's main form.
  • Drag an AMIgoCommandPanel on the form and set it's 'Dock' property to 'Top'.
  • Drag an AMIgoStatusStrip on the form and set it's 'Dock' property to 'Bottom'.
  • From the Toolbox' Containers tab, drag a SplitContainer and set it's Orientation property to 'Horizontal' and the 'Dock' property to 'Fill'.
  • From the Tollbox' AMIgo tab, drag a ListViewLines object in the top panel of the Split Container and set it's 'Dock' property to 'Fill'.
  • From the Tollbox' AMIgo tab, drag a ListViewChannels object in the bottom panel of the Split Container and set it's 'Dock' property to 'Fill'.
  • Click on the AMI_Client and select the Event Tab from the properties windows, then double click on the PeerDetailsEvent then on ChannelDetailsEvent.
  • Edit Form1.cs to add the lines shown below to the two events handlers.
  • Build the application and run it.

CopyC#
 1using System.Windows.Forms;
 2using AMIgo;
 3
 4namespace AMIgoExample1
 5{
 6  public partial class Form1 : Form
 7  {
 8    public Form1()
 9    {
10      InitializeComponent();
11    }
12    //+===========================================================+
13    private void AMI_Client_PeerDetailsEvent(object sender, AMIgo.StringMsgEventArgs ev)
14    {
15      AMIgoDisplayForm df = new  AMIgoDisplayForm("Peer Details", ev.string_msg);
16      df.Show();
17    }
18    //+===========================================================+
19    private void AMI_Client_ChannelDetailsEvent(object sender, StringMsgEventArgs ev)
20    {
21      AMIgoDisplayForm df = new AMIgoDisplayForm("Channel Details", ev.string_msg);
22      df.Show();
23    }
24    //+===========================================================+
25  }
26}

You can now click on the Connection button in the Command Panel toolbar and enter a new Asterisk site definition. You must enter the Host name (or IP address) the port (default 5038), the Asterisk Manager UserName and Password. Then click the save button and finally the connect button or double click on the first column of the new site.

Once connected and logged in, the AMI client will retreive the PBX objects status and display the extensions and trunks and any active channel in the ListView displays.

Tip

You can also fill the AMI_Client AstMngrHost, AstMngrPort, AstMngrUserName and AstMngrPassword and leave the AutoStart and AutoLogin properties to the default of 'true' to have the AMI_Client connect and loggin to the given Asterisk system Manager on startup.