62 lines
1.5 KiB
JavaScript
62 lines
1.5 KiB
JavaScript
import { connect } from "smpp";
|
|
import fs from "fs";
|
|
|
|
const optionsFile = "smpp_tester_options.json";
|
|
|
|
const exampleSession = {
|
|
url: "smpp://172.17.77.203:4445",
|
|
connection_count: 1,
|
|
system_id: "snt",
|
|
password: "snt",
|
|
source_addr: "44455",
|
|
destination_addr: "test123",
|
|
short_message: "SNT BENCHMARK!",
|
|
message_count: 100,
|
|
};
|
|
|
|
if (!fs.existsSync(optionsFile)) {
|
|
fs.writeFileSync(optionsFile, JSON.stringify([exampleSession], null, 4));
|
|
process.exit(1);
|
|
}
|
|
const options = fs.readFileSync(optionsFile, "utf8") ?? "[]";
|
|
const sessions = JSON.parse(options);
|
|
const smppSessions = [];
|
|
|
|
for (const session of sessions) {
|
|
for (let i = 0; i < session.connection_count; i++) {
|
|
const smppSession = connect(
|
|
{
|
|
url: session.url,
|
|
auto_enquire_link_period: 10000,
|
|
debug: true,
|
|
},
|
|
function () {
|
|
smppSession.bind_transceiver({
|
|
system_id: session.system_id,
|
|
password: session.password,
|
|
});
|
|
}
|
|
);
|
|
smppSessions.push({ properties: session, session: smppSession });
|
|
}
|
|
}
|
|
|
|
setTimeout(function () {
|
|
for (const session of smppSessions) {
|
|
for (let i = 0; i < session.properties.message_count; i++) {
|
|
session.session.submit_sm(
|
|
{
|
|
source_addr: session.properties.source_addr,
|
|
destination_addr: session.properties.destination_addr,
|
|
short_message: session.properties.short_message,
|
|
},
|
|
function (pdu) {
|
|
if (pdu.command_status === 0) {
|
|
console.log(pdu.message_id);
|
|
}
|
|
}
|
|
);
|
|
}
|
|
}
|
|
}, 1000);
|