Cleaning up the code and removing hacks for UDH headers. Also code now complies to all the test scenarios.
This commit is contained in:
+13
-5
@@ -368,21 +368,29 @@ function longSms(pduObj) {
|
||||
// reference number is of one octet otherwise it consists of 2 octets. Other fields can
|
||||
// be found from below reference.
|
||||
// reference: https://en.wikipedia.org/wiki/Concatenated_SMS
|
||||
var longSmsId = pduObj.params.source_addr + '_' + pduObj.params.destination_addr + '_' + pduObj.params.udhHeader.reference;
|
||||
var udhHeaderSize = pduObj.params.short_message[0], // First octet is the size of UDH Header
|
||||
headerSize = pduObj.params.short_message[2], // Header size other than first 2 octets
|
||||
csmsReference = pduObj.params.short_message.slice(3, 3 + headerSize - 2), // CSMS Reference starts from
|
||||
// 4th octet and length is
|
||||
// header size -2 octets
|
||||
partsCount = pduObj.params.short_message[2 + csmsReference.length + 1],
|
||||
partNr = pduObj.params.short_message[2 + csmsReference.length + 1];
|
||||
|
||||
var longSmsId = pduObj.params.source_addr + '_' + pduObj.params.destination_addr + '_' + csmsReference;
|
||||
|
||||
if (this.longSmses[longSmsId] === undefined) {
|
||||
this.longSmses[longSmsId] = {
|
||||
'created': new Date(),
|
||||
'partsCount': pduObj.params.udhHeader.totalParts,
|
||||
'udhSize': pduObj.params.udhHeader.size, // Saving udh size to remove garbage from message
|
||||
'partsCount': partsCount,
|
||||
'udhSize': udhHeaderSize, // Saving udh size to remove garbage from message
|
||||
'pduObjs': [{
|
||||
'partNr': pduObj.params.udhHeader.partNr, // We save this here to easier sort the array later on
|
||||
'partNr': partNr, // We save this here to easier sort the array later on
|
||||
'pduObj': pduObj
|
||||
}]
|
||||
};
|
||||
} else {
|
||||
this.longSmses[longSmsId].pduObjs.push({
|
||||
'partNr': pduObj.params.udhHeader.partNr, // We save this here to easier sort the array later on
|
||||
'partNr': partNr, // We save this here to easier sort the array later on
|
||||
'pduObj': pduObj
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user