Some updates
This commit is contained in:
+100
-8
@@ -94,11 +94,6 @@ function session(sock) {
|
||||
var pduObj = pdu,
|
||||
err = null;
|
||||
|
||||
// Make sure the sequence number is set and is correct
|
||||
if ( ! Buffer.isBuffer(pdu)) {
|
||||
pdu.seqNr = returnObj.ourSeqNr;
|
||||
}
|
||||
|
||||
// Make sure the pdu is an object
|
||||
if (Buffer.isBuffer(pdu)) {
|
||||
smppUtils.pduToObj(pdu, function(err, pduObj) {
|
||||
@@ -112,7 +107,10 @@ function session(sock) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.debug('larvitsmpp: lib/session.js: session() - returnObj.send() - Sending PDU to remote. cmdName: ' + pdu.cmdName + ' seqNr: ' + pdu.seqNr);
|
||||
// Make sure the sequence number is set and is correct
|
||||
pduObj.seqNr = returnObj.ourSeqNr;
|
||||
|
||||
log.debug('larvitsmpp: lib/session.js: session() - returnObj.send() - Sending PDU to remote. cmdName: ' + pduObj.cmdName + ' seqNr: ' + pduObj.seqNr);
|
||||
|
||||
// If closeAndSend is omitted, put callback in its place
|
||||
if (typeof closeAfterSend === 'function') {
|
||||
@@ -209,7 +207,7 @@ function session(sock) {
|
||||
* from - alphanum or international format
|
||||
* to - international format
|
||||
* message - string
|
||||
* dlr - boolean defaults to false
|
||||
* dlrRequested - boolean defaults to false
|
||||
* @param func callback(err, smsId, retPduObj)
|
||||
*/
|
||||
returnObj.sendSms = function(smsOptions, callback) {
|
||||
@@ -223,7 +221,7 @@ function session(sock) {
|
||||
};
|
||||
|
||||
// Request DLRs!
|
||||
if (smsOptions.dlr) {
|
||||
if (smsOptions.dlrRequested) {
|
||||
pduObj.params.registered_delivery = 0x01;
|
||||
}
|
||||
|
||||
@@ -234,6 +232,99 @@ function session(sock) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Send a DLR
|
||||
*
|
||||
* @param obj sms - sms object
|
||||
* @param bol status - defaults to true
|
||||
* @param func callback(err)
|
||||
*/
|
||||
returnObj.sendDlr = function(sms, status, callback) {
|
||||
var shortMessage = 'id:' + sms.smsId + ' sub:001 ',
|
||||
err,
|
||||
dlrPduObj;
|
||||
|
||||
if (typeof status === 'function') {
|
||||
callback = status;
|
||||
status = true;
|
||||
}
|
||||
|
||||
if (status === undefined) {
|
||||
status = true;
|
||||
}
|
||||
|
||||
if (status) {
|
||||
shortMessage += 'dlvrd:1 ';
|
||||
} else {
|
||||
shortMessage += 'dlvrd:0 ';
|
||||
}
|
||||
|
||||
shortMessage += 'submit date:' + smppUtils.smppDate(sms.submitTime);
|
||||
shortMessage += ' done date:' + smppUtils.smppDate(new Date());
|
||||
|
||||
if (status) {
|
||||
shortMessage += ' stat:DELIVRD err:0 text:xxx';
|
||||
} else {
|
||||
shortMessage += ' stat:UNDELIVERABLE err:1 text:xxx';
|
||||
}
|
||||
|
||||
dlrPduObj = {
|
||||
'cmdName': 'deliver_sm',
|
||||
'params': {
|
||||
'source_addr': sms.from,
|
||||
'destination_addr': sms.to,
|
||||
'esm_class': 4,
|
||||
'short_message': shortMessage
|
||||
},
|
||||
'tlvs': {
|
||||
'receipted_message_id': {
|
||||
'tagId': 0x001E,
|
||||
'tagName': 'receipted_message_id',
|
||||
'tagValue': sms.smsId
|
||||
},
|
||||
'message_state': {
|
||||
'tagId': 0x0427,
|
||||
'tagName': 'message_state',
|
||||
'tagValue': 2
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if ( ! status) {
|
||||
dlrPduObj.tlvs.message_state.tagValue = 5;
|
||||
}
|
||||
|
||||
dlrPduObj.seqNr = 323;
|
||||
|
||||
console.log('before:');
|
||||
console.log(dlrPduObj);
|
||||
|
||||
smppUtils.objToPdu(dlrPduObj, function(err, pdu) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
smppUtils.pduToObj(pdu, function(err, newObj) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log('newObj:');
|
||||
console.log(newObj);
|
||||
});
|
||||
});
|
||||
|
||||
return;
|
||||
returnObj.send(dlrPduObj, function(err, retPduObj) {
|
||||
console.log('WHATTA WHATTA');
|
||||
console.log(retPduObj);
|
||||
|
||||
/*if (typeof callback === 'function') {
|
||||
callback(err, retPduObj.params.message_id, retPduObj);
|
||||
}*/
|
||||
});
|
||||
};
|
||||
|
||||
// Handle incoming deliver_sm
|
||||
returnObj.deliverSm = function(pduObj) {
|
||||
var dlrObj;
|
||||
@@ -279,6 +370,7 @@ function session(sock) {
|
||||
smsObj = {
|
||||
'from': pduObj.params.source_addr,
|
||||
'to': pduObj.params.destination_addr,
|
||||
'submitTime': new Date(),
|
||||
'message': pduObj.params.short_message,
|
||||
'dlrRequested': Boolean(pduObj.params.registered_delivery)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user