首页 > 解决方案 > 如何使用 AsterNET、C# 发送操作?

问题描述

我正在使用 AsterNET 和 C#,我需要获取所有扩展的状态,特别是 Action: ExtensionStateList 但库没有此操作的结果,我正在尝试创建它但我无法获得它。我希望有人可以指导我。附上代码。

    ResponseEvents re;
    try
    {
        re = manager.SendEventGeneratingAction(new ExtensionStateListAction());
    }
    catch (EventTimeoutException e)
    {
        re = e.PartialResult;
    }
    foreach (ManagerEvent e in re.Events)
    {
        foreach (KeyValuePair<string, string> d in e.Attributes)
        {
            Console.WriteLine(e);
        }
    }

using System;
using AsterNET.Manager.Event;
namespace AsterNET.Manager.Action
{
    public class ExtensionStateListAction : ManagerActionEvent
    {

        public override string Action
        {
            get { return "ExtensionStateList"; }
        }

        public override Type ActionCompleteEventClass()
        {
            return typeof (ExtensionStateListCompleteEvent);
        }
    }
}

namespace AsterNET.Manager.Event
{
    public class ExtensionStateListCompleteEvent : ResponseEvent
    {
        private int listItems;

        public int ListItems
        {
            get { return this.listItems; }
            set { this.listItems = value; }
        }

        public ExtensionStateListCompleteEvent(ManagerConnection source) 
            : base(source)
        {
        }
    }
}

标签: c#visual-studio-2015asteriskasternet

解决方案


此命令的结果将出现在一组事件“ExtensionState”和最终“ExtensionStateCompleate”中

这将是异步的。

您应该设置事件侦听器并对其进行解析。


推荐阅读