Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Forms;
- using AsterNET.FastAGI;
- using AsterNET.FastAGI.MappingStrategies;
- using System.Threading;
- namespace test_calls
- {
- static class Program
- {
- /// <summary>
- /// Главная точка входа для приложения.
- /// </summary>
- [STAThread]
- static void Main()
- {
- Thread test = new Thread(qwe);
- test.Start();
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new Form1());
- }
- static void qwe()
- {
- AsteriskFastAGI agiServer = new AsteriskFastAGI();
- agiServer.MappingStrategy = new GeneralMappingStrategy(
- new List<ScriptMapping>()
- {
- new ScriptMapping() {
- ScriptName = "redialer",
- ScriptClass = "test_calls.ReDialerAGI"
- }
- });
- agiServer.Start();
- }
- }
- }
- //ReDialerAGI.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using AsterNET.FastAGI;
- namespace test_calls
- {
- public class ReDialerAGI : AGIScript
- {
- public override void Service(AGIRequest param1, AGIChannel param2)
- {
- //some actions?
- Answer();
- }
- }
- }
- //Form1.cs
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using AsterNET.Manager.Event;
- using AsterNET.Manager;
- using AsterNET.FastAGI;
- namespace test_calls
- {
- public partial class Form1 : Form
- {
- public static ManagerConnection manager;
- public static NewStateEvent info;
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string user = "user1";
- string password = "GhjcnjNFR456";
- string adress = "194.34.182.35";
- manager = new ManagerConnection(adress, 5038, user, password);
- manager.NewState += new NewStateEventHandler(manager_Events);
- try
- {
- this.Cursor = Cursors.WaitCursor;
- manager.Login();
- }
- catch (Exception ex)
- {
- MessageBox.Show("Error!");
- }
- this.Cursor = Cursors.Default;
- }
- public static void manager_Events(object sender, ManagerEvent e)
- {
- info = (NewStateEvent)e;
- //Answered call
- if (info.ChannelState == "6")
- {
- // MessageBox.Show("Dispatcher" + Global.info.CallerIdName + " has received a call " + e.Attributes["connectedlinename"]);
- }
- if (info.ChannelState == "4")
- {
- test();
- }
- // else
- // MessageBox.Show(info.ChannelStateDesc);
- }
- public static void test()
- {
- button2.Visible=true;
- MessageBox.Show("Someone is ringing!");
- }
- private void button2_Click(object sender, EventArgs e)
- {
- //Answer(); ????????
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement