handleMessage() always sends a response
MLLP doesn't require a response to be sent to an ACK. If you set up two instances of twisted-hl7 talking to each other, each one will ACK the other's ACKs, resulting in an infinite loop.
Moreover, the API doesn't provide a way to implement this.
In dataReceived's enclosed function onSuccess(), simply capture a False result of some kind. If handleMessage returns None or '', onSuccess does nothing. Then, ACK can be handled by returning None.
https://github.com/johnpaulett/twisted-hl7/pull/6/files
@corydodt Thanks!
I'm ok merging this PR if you add some test coverage.
Alternatively, perhaps instead of using a inner function of for onSuccess, we can make the Receiver define it's onSuccess management strategy (I haven't thought through exactly how to do this so perhaps it is not ideal).
Sounds good. I'll keep the scope as-is (inner function) for now, and add test coverage.
Thanks!
This should be fixed by this commit https://github.com/johnpaulett/twisted-hl7/commit/cde15f6ff50ae4e9c077d3edf4a3641252897c01#diff-645924d0286b5e86921ce11a152fb37aL101
writeMessage now checks if message is None and does nothing, so your receivers handleMessage can return None to stop the loop.