Geeks With Blogs

Lance's TextBox
You can interact with Asterisk over TCP and receive PBX event notifications. The Asterisk Manager API, while sparsely documented at voip-info.org is easy enough to follow. Here's how you can connect to Asterisk with the IPPort component of IP*Works!:
ipport1.SendLine("Action: Login\r\nUsername: " + user + "\r\nSecret: " + password + "\r\n"); 

At this point you'll start receiving PBX "events" (such as lines being picked up, lines being connected, voice mails received, etc) which you can catch in the IPPort component's DataIn event.

You'll get a NewChannel event when some action has been performed by some phone to cause a new channel to be opened on the SIP server.
You'll get a NewExtension event when a particular extension (ie, a Zap line or a local SIP phone) has been connected to the channel.
You'll get a NewState event when a particular extension has changed state (such as, "ringing", "up", or "down").
You'll get a Link event when two channels are linking together (conversation is beginning) or and Unlinkevent when two chanels are unlinking from each other (conversation is ending).
You'll get a Voicemail event when a voicemail gets left for a particular extension.

These events let you track who is on the phone, and who they're on the phone with. You can determine if someone is calling you, and who that someone is (caller id). You can determine if there are voicemails on any extensions that you have control over.

I used this functionality to keep a list of call history, so that I can call someone back with just the click of the mouse. I can send an action command to the server to make the phone call for me. When the person I am calling picks up (if they are a SIP extension) or when the outside line is dialed (if they are an outside Zap caller), my own SIP phone will ring notifying me that the conversation is ready.

private void CallNumber(string number, bool local)
{
     string command = "";
     if (local)
     {
          command = "Action: Originate\r\nChannel: SIP/" + number + "\r\n";
          command += "Context: default\r\n";
          command += "Exten: " + myextension + "\r\n";
          command += "Priority: 1\r\n";
          command += "Callerid: \"" + myext + "\" <" + myext + ">\r\n";
     }
     else
     {
          command = "Action: Originate\r\n";
          command += "Channel: Zap/g1/" + number + "\r\n";
          command += "Context: default\r\n";
          command += "Exten: " + myext + "\r\n";
          command += "Priority: 1\r\n";
          command += "Callerid: \"" + myext + "\" <" + myext + ">\r\n";
     }
     ipport1.SendLine(command);
}

Posted on Friday, June 10, 2005 6:22 PM Programming | Back to top


Comments on this post: Interact with SIP server via TCP

# re: Interact with SIP server via TCP
Requesting Gravatar...
How do I do this without IP*Works! ?
Left by Carlos E. Bieberach on Jul 27, 2005 12:08 PM

# re: Interact with SIP server via TCP
Requesting Gravatar...
Carlos, you can do this with any TCPIP library, wether it be IP*Works! or anything else. I use IPWorks for two reasons: #1, I work at /n software, the company that makes IPWorks; #2, using IPWorks is extremely easy and allows for faster development.
Left by Lance on Jul 27, 2005 12:14 PM

# re: Interact with SIP server via TCP
Requesting Gravatar...
I use IP*Works!. You will find me as GTM Systems. A company called Maritime out of Miramar Florida uses my system to process Credit Cards with Vital. For asterisk I want to see what I can do with winsock.
Left by Carlos E. Bieberach on Jul 27, 2005 7:10 PM

# re: Interact with SIP server via TCP
Requesting Gravatar...
Sometime soon I'll post a C# project that does some things with Asterisk (mostly with its event manager api). Until then, if you just can't wait - send me an email (you can do so through the Contact link in the page menu) and I'll send you the project.
Left by Lance on Jul 28, 2005 6:17 AM

# re: Interact with SIP server via TCP
Requesting Gravatar...
Thanks for sharing the details!i would like to more information from your side!please added more then tips!Am working in used laptop dealer in chennaishould you need for any further clarification do not hesitate to reach us back.044-421 27512
Left by Chaaru.v on May 19, 2015 1:55 AM

Your comment:
 (will show your gravatar)


Copyright © Lance Robinson | Powered by: GeeksWithBlogs.net