Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example how to receive large messages? #169

Open
javadevmtl opened this issue May 3, 2022 · 3 comments
Open

Example how to receive large messages? #169

javadevmtl opened this issue May 3, 2022 · 3 comments
Labels

Comments

@javadevmtl
Copy link

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

@pmoerenhout
Copy link
Member

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
Copy link

Ruhshan commented Jul 3, 2023

@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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants