Roave / shorty

An asynchronous SMPP client and server built on Node.js. Shorty is sponsored and maintained by SMS Cloud, a subsidiary of Roave
http://roave.com/
GNU General Public License v3.0
92 stars 52 forks source link

Clarity on Authourization regarding ESME server connections. #17

Open acaciabengo opened 9 years ago

acaciabengo commented 9 years ago

With reference to the methods below. How exactly does authourization of ESME to the SMPP server occur. I would wish to call an API on my ruby app to cross check info and balance as part of authourization and go on to send submit message

self.handleBind = function(pdu) { switch (pdu.command_id) { case smpp.commands.bind_receiver: self.bind_type = smpp.RECEIVER; break; case smpp.commands.bind_transceiver: self.bind_type = smpp.TRANSCEIVER; break; case smpp.commands.bind_transmitter: self.bind_type = smpp.TRANSMITTER; break; }

    // Ask the callback (if there is one) if the credentials are okay
    if (self.listeners('bind').length > 0) {
        self.emit('bind', self, pdu, function(status) {
            self.bindAuthorization(pdu, status);
        });
    } else {
        self.bindAuthorization(pdu, "ESME_ROK");
    }
};

self.bindAuthorization = function(pdu, status) {
    var newPdu, command;

    switch (self.bind_type) {
        case smpp.RECEIVER:
            command = "bind_receiver_resp";
            break;
        case smpp.TRANSMITTER:
            command = "bind_transmitter_resp";
            break;
        case smpp.TRANSCEIVER:
            command = "bind_transceiver_resp";
            break;
    }

    newPdu = {
        command: command,
        command_status: status,
        sequence_number: pdu.sequence_number,
        fields: {
            system_id: self.config.system_id
        },
        optional_params: {}
    };

    // Create a new PDU with our response
    if (status === "ESME_ROK") {
        self.system_id = pdu.system_id.toString('ascii');
        self.bound = true;
        self.socket.setTimeout(self.config.timeout * 1000);
        self.socket.on('timeout', self.enquire_link);
    } else {
        self.bound = false;
        self.bind_type = smpp.UNBOUND;
    }

    self.sendPdu(newPdu);

    self.emit('bindSuccess', self, pdu);
};