opentelecoms-org / jsmpp

SMPP implemented in Java
Apache License 2.0
232 stars 164 forks source link

SMSC randomly send deliver_sm through TX or RX #157

Open coolbeevip opened 3 years ago

coolbeevip commented 3 years ago

I have SMSC devices that only support SMPP 3.3 protocol, But it will randomly send deliver_sm through TX or RX.

I want to be compatible with it. I found the following method

https://github.com/opentelecoms-org/jsmpp/blob/c7599e5d2fc62892b92e009da15337bb70f2c8af/jsmpp/src/main/java/org/jsmpp/session/state/SMPPSessionBoundTX.java#L146

I modify the method like :

  public void processDeliverSm(Command pduHeader, byte[] pdu,
    ResponseHandler responseHandler) throws IOException {
    boolean enableReceiveDeliverSm = Boolean.getBoolean("enableReceiveDeliverSm");
    if (bindTxDeliverSmEnabled) {
      processDeliverSm0(pduHeader, pdu, responseHandler);
    } else {
      responseHandler.sendNegativeResponse(pduHeader.getCommandId(),
        SMPPConstant.STAT_ESME_RINVBNDSTS, pduHeader
          .getSequenceNumber());
    }
  }

Is that correct?

pmoerenhout commented 3 years ago

That looks OK to me.

coolbeevip commented 3 years ago

Thank you, I have verified and solved this issue. Do you accept PR or I should just go ahead and fork it?

pmoerenhout commented 3 years ago

I will refactor it, so it will fully support SMPP 3.3. You can fork it for now.

coolbeevip commented 3 years ago

I noticed that PR[1] tried to solve this problem, But it looks not finished yet.

[1] https://github.com/opentelecoms-org/jsmpp/commit/e6a9bd96ef522de82f5e6eee428a300351818f0d#diff-14b8e22a1fe560a9de6245326de2fcfcef51d6a01b3e8520b02bf071bb79796fR150-R156

coolbeevip commented 3 years ago

Personally, I think to define setInterfaceVersion() method in SMPPSessionState

public interface SMPPSessionState extends GenericSMPPSessionState {

    // add interface
    void setInterfaceVersion(final InterfaceVersion interfaceVersion);

And, Set interface version in the changeState() method

public class SMPPSessionContext extends AbstractSessionContext {

    @Override
    protected void changeState(SessionState newState) {
        if (!stateProcessor.getSessionState().equals(newState)) {
            final SessionState oldState = stateProcessor.getSessionState();
            ...
            } else if (newState == SessionState.BOUND_TX) {
                stateProcessor = SMPPSessionState.BOUND_TX;

                // set interface version
                stateProcessor.setInterfaceVersion(this.getInterfaceVersion());

            } else if (newState == SessionState.BOUND_TRX) {
           ...
        }
    }

}