[asterisk-users] [Asterisk-Java] SipShowPeerAction

Tim Panton tim at mexuar.com
Wed Oct 4 15:06:39 MST 2006


On 4 Oct 2006, at 16:33, richard Coco wrote:

> Hi all,
>
> first of all sorry for the question. I know there is
> an asterisk-java mailinglist but i am not subscribed
> to this list and i am sure there are asterisk-java
> guru on this list who can help me.
>
> I am trying to get the status of a peer using
> "SipShowPeerAction". Unfortunately the getStatus
> method gives me everytime "null".
>
> SipShowPeerAction sipShowPeerAction = new
> SipShowPeerAction("2001");
> 		managerConnection.sendAction(sipShowPeerAction);
> 		PeerEntryEvent peerEntryEvent = new
> PeerEntryEvent(sipShowPeerAction);
> 		System.out.println(peerEntryEvent.getStatus());
>
> What wrong with this example? Maybe someone can give
> me a working example.

The way Java normally works is that you add register yourself as an
event listener, and the framework then sends you an event when  
something happens.

so your class needs to implement ManagerEventListener
then you say something like :

void doit(){
	managerConnection.addEventListener(this)
	SipShowPeerAction sipShowPeerAction = newSipShowPeerAction("2001");
	managerConnection.sendAction(sipShowPeerAction);

}

public void onManagerEvent(ManagerEvent event) {
	if (event instanceof PeerEntryEvent){
		System.out.println(((PeerEntryEvent)event).getStatus());
	} else {
		System.out.println("Some other event");
	}
}


Tim Panton

www.mexuar.com





More information about the asterisk-users mailing list