From 93fdf8c83ab8a3da9f20abc6d51c560837d30c98 Mon Sep 17 00:00:00 2001 From: lilleman Date: Sat, 13 Jun 2015 15:58:55 +0200 Subject: [PATCH] Moved yet another function to pre declaration instead of inline. Also made sure references for smsGroupIds work as expected even if they are several --- lib/session.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) 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,