Un able to trigger read packet function when i receive data using XBee-arduino Library


I have a arduino board with two sensors connected to it. I want to transmit sensor data wirelessly using Xbee communication using API mode. For implementing this i have one Xbee module configured with router API Firmware at Arduino and the other one with Co-ordinator API Firmware. I am using Xbee-arduino Library for performing this(https://code.google.com/p/xbee-arduino/). when i transmit data from co-ordinator to router, Router is able to receive data is but by i am unable to read the packet as there is no sync between the Xbee.readpacket() function(Provided by library to read data packet from xbee module). Can any one suggest me some solution how to overcome this or some method of configuring listener to be called when ever a data received like onreceive(Sample) method in wire library provided by arduino ?

May I suggest checking with one of the Arduino News Groups? I state this as that code you are using is not something that Digi wrote or supports. It is only supported by the person who wrote it.