如何使用 AsterNET、C# 发送操作?

How to send action with 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)
        {
        }
    }
}

此命令的结果将出现在事件集 "ExtensionState" 和最终 "ExtensionStateCompleate"

它将是异步的。

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