How to implement phone using asterisk-im?

I want to implement asterisk-im for create phone that build in jabber client(buddyspace) then I writed this code:

conn = new XMPPConnection(“server”);

conn.login(“poy”,“secret”);

client = new PhoneClient(conn);

client.addEventListener(new BasePhoneEventListener() {

// Override the handleRing event to see when we are receiving a call

public void handleRing(RingEvent event) {

System.out.println("receiving a call from "+ event.getCallerID());

//log.info("receiving a call from " + event.getCallerID());

}

});

client.dialByExtension(“poy1”);

I did not understand why when I dialByextension(“poy1”) but it call to “poy”.

It seems that it call to user that login. It’'s always play congraturation …

But when I use softphone call to softphone, it worked correctly.

Or I edited configure file incorrectly.

And I do not know how to write code to answer a call.

Could you please give me some example that implement phone client.

Please help