Fixed msg decoding issue and cleaning up in long messages queue

This commit is contained in:
2015-06-03 16:52:15 +02:00
parent f157672c49
commit db766927f3
2 changed files with 8 additions and 6 deletions
+5 -5
View File
@@ -504,8 +504,10 @@ function session(sock) {
return 0;
}
// Callback function for emitted sms event
// Call when complete SMS is received
function smsReceived() {
returnObj.emit('sms', smsObj);
// This needs to be ran if DLRs are sent for these messages
delete returnObj.longSmses[smsGroupId];
}
@@ -518,7 +520,6 @@ function session(sock) {
log.debug('larvitsmpp: lib/session.js: session() - returnObj.checkLongSmses() - All parts accounted for in smsGroupId "' + smsGroupId + '", emitting sms event.');
smsObj = {
// These are needed for references here and there in functions
'session': returnObj,
'pduObjs': smsGroup.pduObjs,
@@ -541,12 +542,11 @@ function session(sock) {
curPduObj = smsObj.pduObjs[i].pduObj;
curPduObj.session = returnObj;
smsObj.message += utils.decodeMsg(curPduObj.params.short_message, curPduObj.params.data_coding, curPduObj.params.short_message[0]);
smsObj.message += utils.decodeMsg(curPduObj.params.short_message, curPduObj.params.data_coding, curPduObj.params.short_message[0] + 1);
i ++;
}
returnObj.emit('sms', smsObj);
smsReceived();
} else if (moment(new Date()).diff(smsGroup.created, 'hours') > 24) {
log.info('larvitsmpp: lib/session.js: session() - returnObj.checkLongSmses() - smsGroupId "' + smsGroupId + '" is removed from returnObj.longSmses due to being older than 24 hours.');
+3 -1
View File
@@ -180,7 +180,9 @@ function decodeMsg(buffer, encoding, offset) {
encoding = 'ASCII';
}
return defs.encodings[encoding].decode(buffer.slice(offset, buffer.length));
log.debug('larvitsmpp: lib/utils.js: decodeMsg() - Decoding msg. Encoding: "' + encoding + '" offset: "' + offset + '" buffer: "' + buffer.toString('hex') + '"');
return defs.encodings[encoding].decode(buffer.slice(offset));
}
function encodeMsg(str) {