From 03716404f0d6580a80ccd0718d1a32411141b553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Majdand=C5=BEi=C4=87?= Date: Tue, 2 May 2023 13:09:00 +0200 Subject: [PATCH] Fix issue where center set to echo would echo every message part Now echo simply does not work with long messages --- .../Postprocessor/Center/EchoPduProcessor.ts | 4 ++-- src/SmppSession.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/PDUProcessor/Postprocessor/Center/EchoPduProcessor.ts b/src/PDUProcessor/Postprocessor/Center/EchoPduProcessor.ts index fb1f01a..4dc71ee 100644 --- a/src/PDUProcessor/Postprocessor/Center/EchoPduProcessor.ts +++ b/src/PDUProcessor/Postprocessor/Center/EchoPduProcessor.ts @@ -10,7 +10,7 @@ export default class EchoPduProcessor extends Postprocessor { processPdu(session: any, pdu: any, entity?: SmppSession | undefined): Promise { return new Promise((resolve, reject) => { - if (!!pdu.command && pdu.command === "submit_sm") { + if (!!pdu.command && pdu.command === "submit_sm" && !pdu.short_message.udh) { let echoPdu = new smpp.PDU('deliver_sm', {...pdu}); echoPdu.source_addr = pdu.destination_addr; echoPdu.destination_addr = pdu.source_addr; @@ -19,4 +19,4 @@ export default class EchoPduProcessor extends Postprocessor { } }); } -} \ No newline at end of file +} diff --git a/src/SmppSession.ts b/src/SmppSession.ts index 051a15b..29edfdf 100644 --- a/src/SmppSession.ts +++ b/src/SmppSession.ts @@ -115,11 +115,11 @@ export default abstract class SmppSession { doSendPdu(pdu: PDU, session: any): Promise { return new Promise((resolve, reject) => { - // let characterSizeBits: number = LongSmsProcessor.getCharacterSizeForEncoding(pdu); - // let maxMessageLength: number = LongSmsProcessor.maxMessageSizeBits / characterSizeBits; - // if (!!pdu.short_message && pdu.short_message.length > maxMessageLength) { - // pdu.short_message = pdu.short_message.substring(0, maxMessageLength); - // } + let characterSizeBits: number = LongSmsProcessor.getCharacterSizeForEncoding(pdu); + let maxMessageLength: number = LongSmsProcessor.maxMessageSizeBits / characterSizeBits; + if (!!pdu.short_message && pdu.short_message.length > maxMessageLength) { + pdu.short_message = pdu.short_message.substring(0, maxMessageLength); + } session.send(pdu, (reply: any) => resolve(reply)); this.eventEmitter.emit(this.EVENT.ANY_PDU_TX, pdu); }); @@ -224,4 +224,4 @@ export default abstract class SmppSession { this.logger.log1(`PDU processor: ${processor.constructor.name}-${this.id} already attached to session`); } } -} \ No newline at end of file +}