Asterisk .NET, how to get channel

Hello All,

i am using Asterisk.NET Manager API that was in C# language,
how to do real-time call recording?

MonitorAction ma = new MonitorAction();
ma.Channel = "SIP/250";
ma.File = "voicefile";
ma.Format = "gsm";
ma.Mix = true;
ManagerResponse mr = manager.SendAction(ma, 10000)

but it returns: error no such channel…
I believe “SIP/250” is incorrect channel, because I saw on Asterisk console is: SIP/250-000000121 …

is there anyway to get active channel?
could anybody please advise? …

Thanks & Regards

Normally you track the call using AMI events.

I doubt anyone else uses that .NET interface.

Check out the documentation for AMI. Use your language of choice to do some sockets interfacing with Asterisk server. Do either the basic authentication or MD5 challenge to start a session. Once you have a session open you can send commands like “Action: CoreShowChannels”

action: coreshowchannels

Response: Success
EventList: start
Message: Channels will follow

Event: CoreShowChannel
Channel: SIP/cust-proxy-000123
UniqueID: dev-media-1.1234
Context: default
Priority: 1
ChannelState: 6
ChannelStateDesc: Up
Application: AppDial
ApplicationData: (Outgoing Line)
CallerIDnum: 150
CallerIDname: Caller1
ConnectedLineNum: 150
ConnectedLineName: Caller1
Duration: 00:00:10
AccountCode: YourAccount
BridgedChannel: SIP/cust-proxy-000123
BridgedUniqueID: dev-media-1.1234

Event: CoreShowChannelsComplete
EventList: Complete
ListItems: 1

From this output that you receive back you can parse out the “Channel” values. To get the channel id for the call you want, you’d also need to parse out caller information. For example if I want to do something to the channel ext 150 is using, I would parse out callerIdnum or some other value as well from this list, and check to make sure it was 150.