use of com.cloudhopper.smpp.pdu.DeliverSm in project traccar by tananaev.
the class ClientSmppSessionHandler method firePduRequestReceived.
@Override
public PduResponse firePduRequestReceived(PduRequest request) {
PduResponse response = null;
try {
if (request instanceof DeliverSm) {
String sourceAddress = ((DeliverSm) request).getSourceAddress().getAddress();
String message = CharsetUtil.decode(((DeliverSm) request).getShortMessage(), smppClient.mapDataCodingToCharset(((DeliverSm) request).getDataCoding()));
Log.debug("SMS Message Received: " + message.trim() + ", Source Address: " + sourceAddress);
boolean isDeliveryReceipt = false;
if (smppClient.getDetectDlrByOpts()) {
isDeliveryReceipt = request.getOptionalParameters() != null;
} else {
isDeliveryReceipt = SmppUtil.isMessageTypeAnyDeliveryReceipt(((DeliverSm) request).getEsmClass());
}
if (!isDeliveryReceipt) {
TextMessageEventHandler.handleTextMessage(sourceAddress, message);
}
}
response = request.createResponse();
} catch (Throwable error) {
Log.warning(error);
response = request.createResponse();
response.setResultMessage(error.getMessage());
response.setCommandStatus(SmppConstants.STATUS_UNKNOWNERR);
}
return response;
}
Aggregations