English 中文(简体)
Detect incoming call with Asterisk and who the call is going to
原标题:

I m currently writing a windows service that uses the Asterisk AMI to detect when a call is coming in and then perform a web request based on who the call is from and who it is going to. Does anyone know of an event in Asterisk that I could listen for the includes both of these details? I need the number of the person outside the system who is calling but anything that I could use to identify the internal phone number being called would be fine, as long as it can be used outside of asterisk.

I was looking at the events and they all have the number of the external caller on them however none of them link to the internal caller other than with the uniqueid which unless I build a Dictionary of these in the service I won t be able to use.

最佳回答

So in the end I managed to do this through using only the AMI and listening for call events. With what we wanted access to I listened for the Newchannel events, Dial events and Hangup events, although if all you are after is the number of who is calling and the number of who they are calling I am pretty sure you could get away with monitoring just the Dial events.

Each time a Newchannel event was received I created a Channel object and added it to a list of Channels that were currently on the Asterisk server. Then, by listening to the Dial events with the Subevent of Begin I was able to extract the unique channel id s of both parties involved in the call and then get the numbers involved. When a Hangup event was received I removed the channel that was being destroyed. This seems to be working great for now although we havent had full time to test it so hopefully it s correct.

问题回答

I do have an idea but you will probably not like the answer :)

We tried to do this and failed so we did something evil :)

What we did were to write agi scripts and them call them using the Manager interface and then scrape the command line.

Stuff like core show channels concise etc, its ikky but it works.. we used regex to parse the string output and then grabbed the info from there, the only issue with doing stuff like that is that you have to watch every time you patch as the output from the command line tends to change patch to patch.

If you do discover a way doing this using the c# api and not using agi i d be very interested but we just couldn t do what we wanted with the api without resorting to agi scripts in the end.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签