* @todo implement functionality to handle Data PDUs.
*/
@Override
public boolean receive (SmppResponseInterface response, long timeout)
{
PDU pdu = null;
try {
myLog.error ("receive - calling getSession ().receive");
pdu = getSession ().receive (timeout);
}
catch (UnknownCommandIdException exc) {
myLog.error ("receive - unknown command", exc);
return false;
}
catch (TimeoutException exc) {
myLog.error ("receive - timeout establishing connection", exc);
return false;
}
catch (PDUException exc) {
myLog.error ("receive - exception in pdu", exc);
return false;
}
catch (NotSynchronousException exc) {
myLog.error ("receive - non synchronous", exc);
return false;
}
catch (IOException exc) {
myLog.error ("receive - io exception (socket problem?)", exc);
return false;
}
if (pdu == null) {
return false;
}
else {
myLog.error ("receive - received pdu: {}", pdu.debugString ());
response.setCommand (SmppCommandType.decode (pdu.getCommandId ()));
if (pdu instanceof DeliverSM) {
DeliverSM deliver = (DeliverSM)pdu;
updateResponse (response, deliver);
// send DeliverSMResp
try {
getSession ().respond (deliver.getResponse ());
}
catch (ValueNotSetException exc) {
myLog.error ("receive - value not set", exc);
return false;
}
catch (WrongSessionStateException exc) {
myLog.error ("receive - session state wrong", exc);
return false;
}
catch (IOException exc) {
myLog.error ("receive - io exception (socket problem?)", exc);
return false;
}
return true;
}
else if (pdu instanceof DataSM) {
DataSM data = (DataSM)pdu;
myLog.error ("receive - data message not supported: {}", data.debugString ());
return false;
}
else {
myLog.error ("receive - pdu not recognised {}", pdu.debugString ());
return false;
}
}
}