Small refactoring
This commit is contained in:
32
center.js
32
center.js
@@ -28,7 +28,6 @@ if (options.help) {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const metricManager = new MetricManager(options);
|
|
||||||
|
|
||||||
verifyDefaults(options, centerOptions);
|
verifyDefaults(options, centerOptions);
|
||||||
verifyExists(options.port, "Port can not be undefined or empty! (--port)", logger);
|
verifyExists(options.port, "Port can not be undefined or empty! (--port)", logger);
|
||||||
@@ -40,6 +39,7 @@ let sent = 0;
|
|||||||
let success = 0;
|
let success = 0;
|
||||||
let failed = 0;
|
let failed = 0;
|
||||||
const sendTimer = new NanoTimer();
|
const sendTimer = new NanoTimer();
|
||||||
|
const metricManager = new MetricManager(options);
|
||||||
|
|
||||||
// TODO: Fix issue where a client disconnecting does not stop this timer
|
// TODO: Fix issue where a client disconnecting does not stop this timer
|
||||||
// TODO: Fix issue where only one session is being utilized because they all share the same timer
|
// TODO: Fix issue where only one session is being utilized because they all share the same timer
|
||||||
@@ -118,6 +118,36 @@ const server = smpp.createServer(
|
|||||||
session.close();
|
session.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
session.on("bind_transmitter", function (pdu) {
|
||||||
|
if (pdu.system_id === options.systemid && pdu.password === options.password) {
|
||||||
|
sessionLogger.info("Client connected");
|
||||||
|
session.send(pdu.response());
|
||||||
|
startInterval(session, sessionLogger);
|
||||||
|
} else {
|
||||||
|
sessionLogger.warn(
|
||||||
|
`Client tried to connect with incorrect login ('${pdu.system_id}' '${pdu.password}')`
|
||||||
|
);
|
||||||
|
pdu.response({
|
||||||
|
command_status: smpp.ESME_RBINDFAIL,
|
||||||
|
});
|
||||||
|
session.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
session.on("bind_receiver", function (pdu) {
|
||||||
|
if (pdu.system_id === options.systemid && pdu.password === options.password) {
|
||||||
|
sessionLogger.info("Client connected");
|
||||||
|
session.send(pdu.response());
|
||||||
|
startInterval(session, sessionLogger);
|
||||||
|
} else {
|
||||||
|
sessionLogger.warn(
|
||||||
|
`Client tried to connect with incorrect login ('${pdu.system_id}' '${pdu.password}')`
|
||||||
|
);
|
||||||
|
pdu.response({
|
||||||
|
command_status: smpp.ESME_RBINDFAIL,
|
||||||
|
});
|
||||||
|
session.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
session.on("enquire_link", function (pdu) {
|
session.on("enquire_link", function (pdu) {
|
||||||
session.send(pdu.response());
|
session.send(pdu.response());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ let sent = 0;
|
|||||||
let success = 0;
|
let success = 0;
|
||||||
let failed = 0;
|
let failed = 0;
|
||||||
const sendTimer = new NanoTimer();
|
const sendTimer = new NanoTimer();
|
||||||
|
const metricManager = new MetricManager(options);
|
||||||
|
|
||||||
function startInterval(session, sessionLogger, metrics) {
|
function startInterval(session, sessionLogger, metrics) {
|
||||||
if (!metrics.progress && options.bars === true) {
|
if (!metrics.progress && options.bars === true) {
|
||||||
@@ -95,8 +96,6 @@ function startInterval(session, sessionLogger, metrics) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const metricManager = new MetricManager(options);
|
|
||||||
|
|
||||||
for (let i = 0; i < options.sessions; i++) {
|
for (let i = 0; i < options.sessions; i++) {
|
||||||
const sessionLogger = createSessionLogger(options, i);
|
const sessionLogger = createSessionLogger(options, i);
|
||||||
sessionLogger.info(`Connecting to ${options.host}:${options.port}...`);
|
sessionLogger.info(`Connecting to ${options.host}:${options.port}...`);
|
||||||
|
|||||||
Reference in New Issue
Block a user