Add timeout support for TcpConnection
Lenny4 opened this issue · comments
In android/src/main/java/com/reactnativethermalprinter/ThermalPrinterModule.java
add parameter int timeout
for function public void printTcp
Then change:
TcpConnection connection = new TcpConnection(ipAddress, (int) port);
to
TcpConnection connection = new TcpConnection(ipAddress, (int) port, (int) timeout);
As com.dantsu.escposprinter.connection.tcp.TcpConnection
already has a constructor with timeout, no more work need to be done.
// com.dantsu.escposprinter.connection.tcp.TcpConnection
public TcpConnection(String address, int port, int timeout)
Yes you are right. Thank you for sharing with us :) . Unfortunately, we are still using version 2.0.11 TcpConnection.java which does not seem to have timeout parameter in the constructor. We might have to upgrade it first, but I am afraid of the breaking changes :). What do you think?
Well if there are breaking changes we will just upgrade the major (3.0.0) version and specify in the Readme the break change between version 2 and 3.
I think it's an important update because when the connection fail, it takes about 1 minute before an error is thrown and during this time the react native app freeze.
I have never develop native android or ios. But if you don't have time to implement this feature I will try to do it as I really need it for my project.
I have never develop native android or ios. But if you don't have time to implement this feature I will try to do it as I really need it for my project.
Thank you, your contribution will mean a lot to us :)