How to clone a PDU
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 ?
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.
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.
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?
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 [email protected] 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 https://github.com/twitter/cloudhopper-smpp/issues/86#issuecomment-89305850 .