OpenSmpp / opensmpp

OpenSmpp - Java library implementing the SMPP protocol, and allowing development of External Short Message Entities (ESMEs) and more.
http://opensmpp.org/
Other
188 stars 169 forks source link

I want to know the phone number of the text I sent in the handleEvent method. What should I do? #55

Closed moonjunchoi closed 3 years ago

moonjunchoi commented 3 years ago

====================================================================== ================================ code ==================================

private class SMPPTestPDUEventListener extends SmppObject implements ServerPDUEventListener { public void handleEvent(ServerPDUEvent event) { this.pdu = event.getPDU();

        if (pdu.isRequest()) {
            synchronized (requestEvents) {
                this.requestEvents.enqueue(event);
                this.requestEvents.notify();
            }
        } else if (this.pdu.isResponse()) {

            System.out.println("--------------------------------------------------\n=====> PDU Listener :: async response received " + this.pdu.debugString() + "\n--------------------------------------------------");

            System.out.println("--------------------------------------------------\n======> PDU response is True or False :: " + this.pdu.isOk() + "\n--------------------------------------------------");

            if(this.pdu.isOk() == false) {
                this.failSendCount++;
                this.phoneNumbers.add("1000000000");
            }

            this.count++;

            if(this.phoneNumCount == this.count) {
                // this.dbManager.addFailList("addFailPhoneNumberInfo", this.seq, phoneNumbers, this.objid);
                this.dbManager.setRowsState("setFirstLowSequenceState", this.seq, this.failSendCount, 3);
            }
        } else {
            System.out.println("PDU of unknown class (not request nor " + "response) received, discarding "
                    + this.pdu.debugString());
        }
    }

I brought a piece of my code.

if pdu.isOK() value is false ====> this.failSendCount++

And I will put the failed number in this.phoneNumbers.add("1000000000"); and store it in database

I would like to get a phone number for which texting failed.

In this.phoneNumbers.add ("1000000000") we will put the phone number that failed to transmit.

How can I get the number that failed to transfer?

paoloc0 commented 3 years ago

The PDU is presumably a submit_sm_resp - if you look that up in the SMPP specification, you will see that the phone number is not available from the PDU. Instead, you have to keep this state on your side, by maintaining a window of unacknowledged requests (e.g. in a Map), using pdu.getSequenceNumber() to determine which PDU in your window the submit_sm_resp relates to.

I suggest spending some time with the SMPP spec - it's pretty much essential if you want to use this library. Read at least all the sections up to and including 2.11 (and note especially mention of Timers), which should give you some design clues.