Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

How to clone a PDU #86

Open
pgoergler opened this issue Apr 2, 2015 · 4 comments
Open

How to clone a PDU #86

pgoergler opened this issue Apr 2, 2015 · 4 comments

Comments

@pgoergler
Copy link

Hello,

I'm trying to write an application which clone Pdu.
So i wonder what is the best way to clone a PDU ?
I try something like:

PduTranscoder transcoder = smppSession.getTranscoder();
Pdu newPdu = transcoder.decode(transcoder.encode(originalPdu));.

But smppSession.getTranscoder() is protected.

Is it possible to change SmppSession.getTranscoder() privacy to public or is there another way ?

@jjlauer
Copy link
Contributor

jjlauer commented Apr 2, 2015

Can you give me an idea why you are cloning the PDU? Just trying to understand the use case. Seems inefficient to decode/encode again just to get a copy of it.

@pgoergler
Copy link
Author

It could be used in a Smpp Server for broadcast PDU (v3.4 does not have broadcast) to each Smpp Client Session connected.
But each client session, have their own sequence number.

It also be used in a store and forward proxy.

Yes it's not efficient, but maybe the more generics.

@krasa
Copy link
Contributor

krasa commented Apr 3, 2015

I implemented a proxy simply by:

    int sequenceNumber = pduRequest.getSequenceNumber();
    pduRequest.removeSequenceNumber();
    pduRequest.removeCommandLength();
    response = forward(pduRequest);
    response.removeCommandLength();
    response.setSequenceNumber(sequenceNumber);

Cloning would be nice for parallel broadcasting - if that's what you need?

@jjlauer
Copy link
Contributor

jjlauer commented Apr 3, 2015

I'd consider a pull request that implements copying of PDUs. I'm not sure
the sequence number (and perhaps a couple other fields) are good to copy.
My first instinct is something like

SubmitSm submit = new SubmitSm(otherSubmit);

And then provide implementations in each concrete PDU.

Alternatively, there are helper libraries that clone for you as well. They
may be sufficient and keep this smpp library a little more simple. Have
you looked into using commons-lang
http://commons.apache.org/lang/api/org/apache/commons/lang/SerializationUtils.html
or a number of other libraries that assist with copying?

On Fri, Apr 3, 2015 at 7:36 AM, Vojtěch Krása notifications@github.com
wrote:

I implemented a proxy simply by:

int sequenceNumber = pduRequest.getSequenceNumber();
pduRequest.removeSequenceNumber();
response = forward(pduRequest);
response.removeCommandLength();
response.setSequenceNumber(sequenceNumber);

Cloning would be nice for parallel broadcasting - if that's what you need?


Reply to this email directly or view it on GitHub
#86 (comment)
.

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

No branches or pull requests

3 participants