我正在运行SMPP服务器。我需要从数据库验证客户端,验证之后需要发送服务器响应。这是我的代码:
var smpp = require("smpp");
var server = smpp.createServer(function(session) {
session.on("bind_transceiver", function(pdu) {
console.log("Client is connected with systemId " + pdu.system_id);
console.log(pdu.command_status);
// session.pause();
// Here i want to validate. How to verify these system_id and password from MongoDB database?
checkAsyncUserPass(pdu.system_id, pdu.password, function(err) {
if (err) {
session.send(
pdu.response({
command_status: smpp.ESME_RBINDFAIL
})
);
session.close();
return;
}
session.send(pdu.response()); // if client is authenticated, then only sends response
session.resume();
});
});
});
function checkAsyncUserPass(id, pw, fn) {
// This is the function where client needs to be verified from database.
return true;
}
server.listen(2775, () => console.log("SMPP Sever is listening at 2775"));
在正常情况下,我可以使用expressjs并发出Http get或post请求。但是如何在SMPP中完成相同的工作?