How to send [Action: ExtensionStateList] with AsterNET?
See original GitHub issueI’m working with AsterNET and C#, I need to get the status of all the extensions, specifically the result of Action: ExtensionStateList but the library doesn’t have this action, I’m trying to create it but I can’t get it. I hope someone can guide me. Attached is the code.
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)
{
}
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
How to send action with AsterNET, C#? - ...
I'm working with AsterNET and C#, I need to get the status of all the extensions, specifically the result of Action: ExtensionStateList but ......
Read more >Newest 'asternet' Questions
I'm working with AsterNET and C#, I need to get the status of all the extensions, specifically the result of Action: ExtensionStateList but...
Read more >Asterisk 13 ManagerAction_ExtensionStateList
Syntax. Action: ExtensionStateList ActionID: <value>. Arguments. ActionID - ActionID for this transaction. Will ...
Read more >ManagerConnection.SendAction Method (ManagerAction)
Send Action with default timeout. ... Assembly: AsterNET (in AsterNET.dll) Version: 1.0.0.0 (1.0.0.0). Syntax. C#. VB. C++. F#. Copy.
Read more >AsterNET.Manager.Action Namespace
The CommandAction sends a command line interface (CLI) command to the asterisk server. For a list of supported commands type help on asterisk's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You have created the
ExtensionStateListAction
action and theExtensionStateListCompleteEvent
event.Aren’t you perhaps missing the
ExtensionStateEvent
event?The Asterisk documentation: https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerAction_ExtensionStateList
I have never used the
SendEventGeneratingAction(...)
method, I normally just catch the events manually. And maybe that is your issue, you are expectingExtensionStateListCompleteEvent
to be aResponseEvent
when it isn’t.Try simply subscribing to the events, send the action like a normal action, and see what you get.
Here is an untested example created using some code I wrote for a similar thing.
Make a simple
ExtensionStateListEventArgs
class with apublic List<ExtensionStateListAction> ExtensionStateList { get; set; }
property.Again this is asynchronous. You call the void
ExtensionStateList()
method, and then wait for theAmiExtensionStateListComplete
event to be raised. I don’t have a good idea about how to make it synchronous, but it shouldn’t be impossible to make it wait or something.