farhadi / node-smpp

SMPP client and server implementation in node.js
MIT License
417 stars 177 forks source link

Differntiate between incoming message and an incoming message that gets triggered after a message is sent using smpp #238

Closed aTrueSeeker closed 1 year ago

aTrueSeeker commented 1 year ago

I noticed that after connecting a transceiver the deliver_sm gets fired after my app sends a message and it looks like image. How can i differentiate between this message and other incoming messages that is being sent

guicuton commented 1 year ago

This message that you received on deliver_smis the DELIVERY REPORT of sent message (DLR) For incoming messages (MO / 2way message) the esm_class param will be different of 4.

Just do a simple if() condition with this and you will be good to go like:

session.on('deliver_sm', (pdu) => {
    if(pdu.esm_class === 4) {
        console.log(pdu, 'DLR');
     }

     if(pdu.esm_class !== 4) {
         console.log(pdu, 'MO');
    }
})
aTrueSeeker commented 1 year ago

Thanks @guicuton for the prompt response. :bow: