use of org.openhab.binding.epsonprojector.internal.EpsonProjectorException in project openhab1-addons by openhab.
the class EpsonProjectorTcpConnector method sendMessage.
/**
* {@inheritDoc}
*/
@Override
public String sendMessage(String data, int timeout) throws EpsonProjectorException {
if (in == null || out == null) {
connect();
}
try {
// flush input stream
if (in.markSupported()) {
in.reset();
} else {
while (in.available() > 0) {
int availableBytes = in.available();
if (availableBytes > 0) {
byte[] tmpData = new byte[availableBytes];
in.read(tmpData, 0, availableBytes);
}
}
}
return sendMmsg(data, timeout);
} catch (IOException e) {
logger.debug("IO error occured...reconnect and resend ones");
disconnect();
connect();
try {
return sendMmsg(data, timeout);
} catch (IOException e1) {
throw new EpsonProjectorException(e);
}
} catch (Exception e) {
throw new EpsonProjectorException(e);
}
}
Aggregations