diff --git a/lib/session.js b/lib/session.js index 02b526b..34d86d5 100644 --- a/lib/session.js +++ b/lib/session.js @@ -455,6 +455,19 @@ function longSms(pduObj) { this.checkLongSmses(); } +// Sort function to sort group parts +function sortLongSmsPdus(a, b) { + if (a.partNr < b.partNr) { + return - 1; + } + + if (a.partNr > b.partNr) { + return 1; + } + + return 0; +} + // Walk through the long sms storage to investigate if we can send complete messages along // or should remove old ones function checkLongSmses() { @@ -467,25 +480,12 @@ function checkLongSmses() { log.silly('larvitsmpp: lib/session.js: checkLongSmses() - Running'); - // Sort function to sort group parts - function sortLongSmsPdus(a, b) { - if (a.partNr < b.partNr) { - return - 1; - } - - if (a.partNr > b.partNr) { - return 1; - } - - return 0; - } - // Call when complete SMS is received function smsReceived() { that.emit('sms', smsObj); // This needs to be ran if DLRs are sent for these messages - delete that.longSmses[smsGroupId]; + delete that.longSmses[smsObj.smsGroupId]; } for (smsGroupId in this.longSmses) { @@ -498,6 +498,7 @@ function checkLongSmses() { smsObj = { // These are needed for references here and there in functions 'session': that, + 'smsGroupId': smsGroupId, 'pduObjs': smsGroup.pduObjs, 'from': smsGroup.pduObjs[0].pduObj.params.source_addr, 'to': smsGroup.pduObjs[0].pduObj.params.destination_addr,