Re: [Asterisk-java-users] help using PeerStatusEvent
Brought to you by:
srt
From: Stefan R. <sr...@re...> - 2005-11-25 10:36:07
|
Hi Aparna, > I would like to get the name of the Peer from asterisk , when it > registers. how shouild i go abt implementing this? > i know i shd luk into PeerStatusEvent. but being new to Java, i would > like some sample code to help me with. you are right about the PeerStatusEvent. Your application will have to listen for events that are received from Asterisk, for each event check if it is a PeerStatusEvent and then do something with it. To get started i suggest you to have a look at the tutorial available at http://www.asteriskjava.org/latest/tutorial.html There you will find the HelloEvents class that already does something similar. It listens for all events received within 10 seconds and prints them to the console. As you are only interested in the PeerStatusEvent you will want to change the handleEvent to check for it: public void handleEvent(ManagerEvent event) { if (event instanceof PeerStatusEvent) { String peerName = ((PeerStatusEvent) event).getPeer(); System.out.println("Got a PeerStatusEvent for " + peerName); } } Of course you probably want to do something more sophisticated that just printing out the name :) Hope that helps you get started. =Stefan Aparna Ramakrishnan schrieb: > Hi all, > > > kindly guide. > > thanks n regards > aparna > > Yahoo! Music Unlimited - Access over 1 million songs. Try it free. > <http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/> > |