Re: [asterisk-users] Asterisk Manager and Visual Basic

2008-02-14 Thread Lee Jenkins
Bill Andersen wrote:
 Has anyone tried to used VB6 to communicate with the Asterisk Manager?
 
 If so, would you be willing to share some basic code showing your
 approach to getting connected and parsing results?
 
 I've got a Telnet control that is allowing me to connect, authenticate
 and see the flow of status, etc., but I'm sure there is a better way
 to do this without using Telnet (maybe not?).  Any suggestions?
 
 I want to write a presence monitor (a virtual sidecar if you will)
 
 Bill
 

As Razza said, you can just use the winsock control included with VB.  The 
protocol is very simple, basically just name/value pairs delimited by #13#10 
(CRLF) with an extra CRLF at the end to denote termination of the packet.

Action: Originate
Channel: local/[EMAIL PROTECTED]
Context: to_meetme
Exten: s
Priority: 1
Variable: CALLERID(num)=123432|CALLERID(name)=Automated Call
Async: true
extra CRLF == extra CRLF here.

So, like this:

1. Send your properly formatted packet to AMI .

2. Read incoming response terminated by double #13#10.

3. Parse values as you are comfortable with.

I am in the process of writing a similar product for one of our customers. 
Well, a re-write to add features and make it cross platform.  Here's a 
screenshot running on Linux/GTK:
http://leebo.dreamhosters.com/images/guiApp.png

A couple of side notes from what I've learned myself and read on this mailing 
list or through the wiki:

1. Packet Volume
The volume of messages that you can get from the AMI is impressive.  I've 
tested 
on our Asterisk system which has only 2 pots lines and two sip trunks with 10 
desktop phones and the amount of messages can be staggering!

Use a proxy for AMI if you have any decent phone traffic.  AstManProxy is VERY 
propular.  I wrote one as well, but its still beta and I think there's another 
one out there somewhere.  Usually with these proxy servers you can filter out 
unwanted/extraneous events to reduce the amount of messages your app has to 
contend with.

2. Make good use of Observer/Mediator pattern to distribute events to different 
parts of your GUI.  Monolithic loops to write everything out on a timer's event 
or after a Sleep() for instance, is not a good way to go in my experience.

3. Check the source for manager interface for changes between Asterisk 1.2 and 
1.4 (and 1.6?) if you're using 1.2 or plan to.  I believe the latest version of 
AMI is 1.1 (someone can correct me here).  A few label names for some of the 
AMI 
packets have been changed and a couple events (like LINK event) have been 
changed drastically.

I originally wrote against the 1.2 Manager interface only to find that I had to 
refactor some code and write descendant classes to handle the slight 
differences 
between the two versions' events.  I could have saved myself some work had I 
thought to look for the changes.  I think this link is up to date:
http://svn.digium.com/view/asterisk/trunk/doc/manager_1_1.txt?revision=98152view=markup

Happy coding.


-- 
Warm Regards,

Lee

Everything I needed to learn in life, I learned selling encyclopedias door to 
door.

___
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Asterisk Manager and Visual Basic

2008-02-14 Thread Bill Andersen
 I don't know if it would be of any use to you but we have some C# code
 that handles the basics of communicating the the Asterisk Manager
 Interface. It doesn't do anything fancy just sends single commands and
 checks the responses. We don't use it for monitoring.
 
 Regards,
 
 Greyman.

Thanks for the offer, I think I've got it figured out using winsock.

Thanks again.

Bill


___
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


[asterisk-users] Asterisk Manager and Visual Basic

2008-02-13 Thread Bill Andersen
Has anyone tried to used VB6 to communicate with the Asterisk Manager?

If so, would you be willing to share some basic code showing your
approach to getting connected and parsing results?

I've got a Telnet control that is allowing me to connect, authenticate
and see the flow of status, etc., but I'm sure there is a better way
to do this without using Telnet (maybe not?).  Any suggestions?

I want to write a presence monitor (a virtual sidecar if you will)

Bill



___
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Asterisk Manager and Visual Basic

2008-02-13 Thread Razza
On 13/02/2008, Bill Andersen [EMAIL PROTECTED] wrote:
 Has anyone tried to used VB6 to communicate with the Asterisk Manager?

 If so, would you be willing to share some basic code showing your
 approach to getting connected and parsing results?
 Bill

I wrote some very very basic stuff ages ago using standard
mswinsck.ocx, will dig it out.

___
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Asterisk Manager and Visual Basic

2008-02-13 Thread Grey Man

- Original Message 

 From: Bill Andersen [EMAIL PROTECTED]

 To: asterisk-users@lists.digium.com

 Sent: Wednesday, 13 February, 2008 8:31:01 PM

 Subject: [asterisk-users] Asterisk Manager and Visual Basic



 Has anyone tried to used VB6 to communicate with the Asterisk Manager?

 If so, would you be willing to share some basic code showing your
 approach to getting connected and parsing results?

 I've got a Telnet control that is allowing me to connect, authenticate
 and see the flow of status, etc., but I'm sure there is a better way
 to do this without using Telnet (maybe not?).  Any suggestions?



Hi Bill,

I don't know if it would be of any use to you but we have some C# code that 
handles the basics of communicating the the Asterisk Manager Interface. It 
doesn't do anything fancy just sends single commands and checks the responses. 
We don't use it for monitoring.

Regards,

Greyman.






  Get the name you always wanted with the new y7mail email address.
www.yahoo7.com.au/y7mail



___
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users