Skip to content

Commit

Permalink
Implement additional way to detect SMPP delivery receipts
Browse files Browse the repository at this point in the history
  • Loading branch information
Abyss777 committed Mar 6, 2018
1 parent 88456dc commit 5ac0f77
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/org/traccar/smpp/ClientSmppSessionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ public PduResponse firePduRequestReceived(PduRequest request) {
smppClient.mapDataCodingToCharset(((DeliverSm) request).getDataCoding()));
Log.debug("SMS Message Received: " + message.trim() + ", Source Address: " + sourceAddress);

if (!SmppUtil.isMessageTypeAnyDeliveryReceipt(((DeliverSm) request).getEsmClass())) {
boolean isDeliveryReceipt = false;
if (smppClient.getDetectDlrByOpts()) {
isDeliveryReceipt = request.getOptionalParameters() != null;
} else {
isDeliveryReceipt = SmppUtil.isMessageTypeAnyDeliveryReceipt(((DeliverSm) request).getEsmClass());
}

if (!isDeliveryReceipt) {
TextMessageEventHandler.handleTextMessage(sourceAddress, message);
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/org/traccar/smpp/SmppClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public class SmppClient {
private String sourceAddress;
private String commandSourceAddress;
private int submitTimeout;
private boolean requestDrl;
private boolean requestDlr;
private boolean detectDlrByOpts;
private String notificationsCharsetName;
private byte notificationsDataCoding;
private String commandsCharsetName;
Expand Down Expand Up @@ -92,7 +93,8 @@ public SmppClient() {
commandSourceAddress = Context.getConfig().getString("sms.smpp.commandSourceAddress", sourceAddress);
submitTimeout = Context.getConfig().getInteger("sms.smpp.submitTimeout", 10000);

requestDrl = Context.getConfig().getBoolean("sms.smpp.requestDrl");
requestDlr = Context.getConfig().getBoolean("sms.smpp.requestDlr");
detectDlrByOpts = Context.getConfig().getBoolean("sms.smpp.detectDlrByOpts");

notificationsCharsetName = Context.getConfig().getString("sms.smpp.notificationsCharset",
CharsetUtil.NAME_UCS_2);
Expand Down Expand Up @@ -153,6 +155,10 @@ public String mapDataCodingToCharset(byte dataCoding) {
}
}

public boolean getDetectDlrByOpts() {
return detectDlrByOpts;
}

protected synchronized void reconnect() {
try {
disconnect();
Expand Down Expand Up @@ -213,7 +219,7 @@ public synchronized void sendMessageSync(String destAddress, String message, boo
byte[] textBytes;
textBytes = CharsetUtil.encode(message, command ? commandsCharsetName : notificationsCharsetName);
submit.setDataCoding(command ? commandsDataCoding : notificationsDataCoding);
if (requestDrl) {
if (requestDlr) {
submit.setRegisteredDelivery(SmppConstants.REGISTERED_DELIVERY_SMSC_RECEIPT_REQUESTED);
}
submit.setShortMessage(textBytes);
Expand Down

0 comments on commit 5ac0f77

Please sign in to comment.