opentelecoms-org / jsmpp

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

Example how to receive large messages? #169

Open javadevmtl opened 2 years ago

javadevmtl commented 2 years ago

Hi is there an example that shows on the server side how to accept a large message?

pmoerenhout commented 1 year ago

A large message should be encoded in the message_payload optional parameter. A server should either use the shortMessage field, or the message_payload optional parameter when the shortMessage is empty.

Ruhshan commented 1 year ago

@javadevmtl

Assuming you are implementing ServerMessageReceiverListener, and there is a method onAcceptSubmitSm , here is a sample to receive long message.

    public SubmitSmResult onAcceptSubmitSm(SubmitSm submitSm, SMPPServerSession smppServerSession) throws ProcessRequestException {

        OptionalParameter messagePayload = submitSm.getOptionalParameter(OptionalParameter.Tag.MESSAGE_PAYLOAD);

        OptionalParameter.OctetString octateString = (OptionalParameter.OctetString) messagePayload;

        String longMessage = octateString.getValueAsString();
        //Or
        String longMessage = new String(os.getValue(), <charset of your choice>);

}

@pmoerenhout Is this a correct way to do this?

pmoerenhout commented 1 year ago

Yes, the getValueAsString will construct the string with the system charset, so explitcitly using new String(os.getValue(), ); is better...