Closed t3hk0d3 closed 10 years ago
I like the idea :-)
In order to log all PDUs sent and received in a a custom format I did something similar (without cloudhopper-smpp modifications), through overriding DefaultSmppClient.createSession() and adding a Netty handler after the "smppSessionPduDecoder".
PDUs received are "Pdu" class instances, while PDUs sent are seen as ChannelBuffer instances. The ChannelBuffer instances then have to be transcoded back to a Pdu to be parsed, not very elegant but it works.
Wouldn't it be more clean to delegate DefaultSmppSession's netty channel writing out to a separate class doing just that, with a single method to write a Pdu? The delegate should be possible to replace/extend. Reading is currently done by SmppSessionWrapper (a Netty ChannelHandler) which notifies of incoming PDUs and closed channels. SmppSessionWrapper is nice, but creation is hardcoded by "new SmppSessionWrapper()" in various difficult to override places, would be better if instances could be injected or were retrieved from an injectable factory to allow for customization.
@stela Hooking up into Netty's pipelines is imho kinda bad idea. It ruins abstraction.
This is a useful feature for sure. I appreciate the quality of the implementation you provided.
This would be great to promote in the demos as well -- could you submit another pull request that adds/modifies one of the demos to show how you can log/discard, etc?
I've met task where i have to send enquire link request only after specified time from any last PDU received. There is only way with overriding
DefaultSMPPSession
andDefaultSMPPClient
, hooking up tofirePduReceived
method, becauseSmppSessionHandler
misses PDU's sent throughWindowFuture
.So i came with solution for low-level hooks for PDU being received or sent. Bonus is you can discard received/sent PDU from further processing/dispatching.
For example this would be handy if you have your own PDU processing pipeline.