private AcpResponse AcpFlow(AcpCommand command) { AliveCheck(); byte fCode = Acp.FCODE_NO_RESPONSE; byte[] dataBuffer = new byte[0]; try { AcpStandardProcess.Send(socket, command.ToBytes()); AcpStandardProcess.Receive(socket, out fCode, out dataBuffer); } catch (AcpTimeOutException) { Logger.Info(this, "timeout.."); fCode = Acp.FCODE_TIMEOUT; } catch (SocketException e) { Logger.Warn(this, $"acp socket exception {e.ToString()}"); fCode = Acp.FCODE_NO_RESPONSE; } catch (IOException e) { Logger.Warn(this, $"acp exception(client reading) {e}"); fCode = Acp.FCODE_ERR_WITH_EX; dataBuffer = Encoding.UTF8.GetBytes(e.ToString() + " " + e.Message); } return(new AcpResponse() { FirstCode = fCode, Data = dataBuffer, }); }
public bool IsAlive() { try { AcpStandardProcess.Send(socket, Encoding.UTF8.GetBytes(Acp.CMD_TEST)); AcpStandardProcess.Receive(socket, out byte fCode, out byte[] data, 5000); return(fCode == Acp.FCODE_SUCCESS); } catch (SocketException e) { Logger.Warn(this, "a exception happend on test ACPService on android is running", e); return(false); } catch (IOException e) { Logger.Warn(this, "a exception happend on test ACPService on android is running", e); return(false); } catch (ObjectDisposedException e) { Logger.Warn("a exception happend on test ACPService on android is running", e); return(false); } }