Asterisk & C#
Following are small code snippets useful in different situations: //// Write Call File// MonoTone mono = new MonoTone();//// "/usr/src/mono/permission.sh is path to executable script//System . Diagnostics . Process proc = System . Diagnostics . Process . Start ( "/usr/src/mono/permission.sh" );WriteLog ( "Process id : " + proc . Id + " " + "/usr/src/mono/permission" + p + ".sh" );mono . HangUp ( ); //// Executing Asterisk native commands// // In following lines of code, response can be any number...
This small program demonstrates how to detect DTMF and log it. using System;using System.IO;using AGI;namespace DtmfDetector{ public class Program { public static void Main( ) { MonoTone mono; String response = ""; Keypad key; mono = new MonoTone ( ); try { String number = ""; while ( true ) { number = mono . GetData ( "Samples/pls-entr-num-uwish... , 10000 , 1 ); WriteLog ( number ); // If the response of GetData contains "time out", it means that user has // responded at time and time is out....
This is a sample calculator to explore more on AGI using System;using AGI;namespace AsteriskGeeks{ public class Program { static void Main ( string [ ] args ) { MonoTone mono = new MonoTone (); Keypad key = new Keypad (); // // Getting input for numbers // String firstNumber = mono . GetData ( "Samples/PleaseEnterYourFir... , 10000 , 1 ); String secondNumber = mono . GetData ( "Samples/PleaseEnterYourFir... , 10000 , 1 ); // // Getting input for type of Operation. // 1 for + // 2 for...
Writing data into file system is always desired by developers. It is a kind of requirement that can come to any kind of program. I give more importance to writing into file system using my code because I use this way as a debugging method also. Following code snippet demonstrates a sample file operation: using System;using System . IO;using AGI;namespace AsteriskGeeks{ public class Program { static void Main ( string [ ] args ) { MonoTone mono = new MonoTone (); Keypad key = new Keypad (); String...
This simple program demonstrates getting input from AGI and replying it back. using System;using AGI;namespace AsteriskGeeks{ public class Program { static void Main ( string [ ] args ) { MonoTone mono = new MonoTone (); Keypad key = new Keypad (); // // GetData method is used to play a sound file Also wait M Mili seconds till timeout // for N number of expected numbers (M second for every 1 digit). // Following line of code will play Please Enter One Number (I have created one folder // named Samples...
using System; using AGI; namespace AsteriskGeeks { public class Program { static void Main ( string [ ] args ) { // // Create an Object for MonoTone class which does all the // communication between Asterisk and C# // MonoTone mono = new MonoTone (); // // KeyPad object is used to hold input from keypad of phone // Keypad key = new Keypad (); // // StreamFile method is used to stream a sound file and return bool // true for successful play and false for failed stream // // // Note: welcome is the...
AGI AGI is Asterisk Gateway interface. It can be used to extend asterisk functionalities with help of different programming/scripting languages like C#, Perl, PHP etc. According to VoIp-info.org AGI may control the dialplan, called in extensions.conf EAGI gives the application the possibility to access and control the sound channel in addition to interaction with the dial plan FastAGI can be used to do the processing on a remote machine DeadAGI gives access to a dead channel, after hang-up. Basically...