Fixed issue with enq link trying on a closed socket
This commit is contained in:
+25
-25
@@ -13,68 +13,68 @@ var log = require('winston'),
|
|||||||
* @return obj (returnObj)
|
* @return obj (returnObj)
|
||||||
*/
|
*/
|
||||||
function clientSession(sock, options) {
|
function clientSession(sock, options) {
|
||||||
var parent = session(sock);
|
var returnObj = session(sock);
|
||||||
|
|
||||||
parent.login = function() {
|
returnObj.login = function() {
|
||||||
var loginPdu = {
|
var loginPdu = {
|
||||||
'cmdName': 'bind_transceiver',
|
'cmdName': 'bind_transceiver',
|
||||||
'seqNr': parent.ourSeqNr,
|
'seqNr': returnObj.ourSeqNr,
|
||||||
'params': {
|
'params': {
|
||||||
'system_id': options.username,
|
'system_id': options.username,
|
||||||
'password': options.password
|
'password': options.password
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
parent.send(loginPdu, function(err, retPduObj) {
|
returnObj.send(loginPdu, function(err, retPduObj) {
|
||||||
if (err) {
|
if (err) {
|
||||||
parent.emit('loginFailed');
|
returnObj.emit('loginFailed');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retPduObj.cmdStatus === 'ESME_ROK') {
|
if (retPduObj.cmdStatus === 'ESME_ROK') {
|
||||||
log.info('larvitsmpp: lib/client.js: clientSession() - parent.login() - Successful login!');
|
log.info('larvitsmpp: lib/client.js: clientSession() - returnObj.login() - Successful login!');
|
||||||
parent.loggedIn = true;
|
returnObj.loggedIn = true;
|
||||||
parent.emit('loggedIn');
|
returnObj.emit('loggedIn');
|
||||||
} else {
|
} else {
|
||||||
log.info('larvitsmpp: lib/client.js: clientSession() - parent.login() - Login failed. Status msg: ' + retPduObj.cmdStatus);
|
log.info('larvitsmpp: lib/client.js: clientSession() - returnObj.login() - Login failed. Status msg: ' + retPduObj.cmdStatus);
|
||||||
parent.emit('loginFailed');
|
returnObj.emit('loginFailed');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
parent.resetEnqLinkTimer = function() {
|
returnObj.resetEnqLinkTimer = function() {
|
||||||
log.silly('larvitsmpp: lib/client.js: clientSession() - resetEnqLinkTimer() - Resetting the kill timer');
|
log.silly('larvitsmpp: lib/client.js: clientSession() - resetEnqLinkTimer() - Resetting the kill timer');
|
||||||
if (parent.enqLinkTimer) {
|
if (returnObj.enqLinkTimer) {
|
||||||
clearTimeout(parent.enqLinkTimer);
|
clearTimeout(returnObj.enqLinkTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
parent.enqLinkTimer = setTimeout(function() {
|
returnObj.enqLinkTimer = setTimeout(function() {
|
||||||
parent.send({
|
returnObj.send({
|
||||||
cmdName: 'enquire_link',
|
cmdName: 'enquire_link',
|
||||||
seqNr: parent.ourSeqNr
|
seqNr: returnObj.ourSeqNr
|
||||||
});
|
});
|
||||||
}, options.enqLinkTiming);
|
}, options.enqLinkTiming);
|
||||||
};
|
};
|
||||||
|
|
||||||
parent.login();
|
returnObj.login();
|
||||||
parent.resetEnqLinkTimer();
|
returnObj.resetEnqLinkTimer();
|
||||||
|
|
||||||
parent.on('incomingPdu', function(pduObj) {
|
returnObj.on('incomingPdu', function(pduObj) {
|
||||||
if (pduObj.cmdName === 'deliver_sm') {
|
if (pduObj.cmdName === 'deliver_sm') {
|
||||||
parent.deliverSm(pduObj);
|
returnObj.deliverSm(pduObj);
|
||||||
} else if (pduObj.cmdName === 'enquire_link') {
|
} else if (pduObj.cmdName === 'enquire_link') {
|
||||||
parent.enquireLink();
|
returnObj.enquireLink();
|
||||||
} else if (pduObj.cmdName === 'submit_sm') {
|
} else if (pduObj.cmdName === 'submit_sm') {
|
||||||
parent.submitSm(pduObj);
|
returnObj.submitSm(pduObj);
|
||||||
} else if (pduObj.cmdName === 'unbind') {
|
} else if (pduObj.cmdName === 'unbind') {
|
||||||
parent.sendReturn(pduObj, 'ESME_ROK', true);
|
returnObj.sendReturn(pduObj, 'ESME_ROK', true);
|
||||||
} else {
|
} else {
|
||||||
// All other commands we do not support
|
// All other commands we do not support
|
||||||
parent.sendReturn(pduObj, 'ESME_RINVCMDID');
|
returnObj.sendReturn(pduObj, 'ESME_RINVCMDID');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return parent;
|
return returnObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+6
-1
@@ -43,6 +43,7 @@ function session(sock) {
|
|||||||
returnObj.closeSocket = function() {
|
returnObj.closeSocket = function() {
|
||||||
log.verbose('larvitsmpp: lib/session.js: session() - closeSocket() - Closing socket for ' + sock.remoteAddress + ':' + sock.remotePort);
|
log.verbose('larvitsmpp: lib/session.js: session() - closeSocket() - Closing socket for ' + sock.remoteAddress + ':' + sock.remotePort);
|
||||||
if (returnObj.enqLinkTimer) {
|
if (returnObj.enqLinkTimer) {
|
||||||
|
log.debug('larvitsmpp: lib/session.js: session() - closeSocket() - enqLinkTimer found, clearing.');
|
||||||
clearTimeout(returnObj.enqLinkTimer);
|
clearTimeout(returnObj.enqLinkTimer);
|
||||||
}
|
}
|
||||||
sock.destroy();
|
sock.destroy();
|
||||||
@@ -341,7 +342,11 @@ function session(sock) {
|
|||||||
// Add a 'close' event handler to this instance of socket
|
// Add a 'close' event handler to this instance of socket
|
||||||
sock.on('close', function() {
|
sock.on('close', function() {
|
||||||
returnObj.emit('close');
|
returnObj.emit('close');
|
||||||
log.debug('larvitsmpp: lib/session.js: session() - socket closed');
|
if (returnObj.enqLinkTimer) {
|
||||||
|
log.debug('larvitsmpp: lib/session.js: session() - sock.on(close) - enqLinkTimer found, clearing.');
|
||||||
|
clearTimeout(returnObj.enqLinkTimer);
|
||||||
|
}
|
||||||
|
log.debug('larvitsmpp: lib/session.js: session() - sock.on(close) - socket closed');
|
||||||
});
|
});
|
||||||
|
|
||||||
return returnObj;
|
return returnObj;
|
||||||
|
|||||||
Reference in New Issue
Block a user