public static String getResponseMaybe ( SocketManager socketManager , String message ) throws IOException { try { return socketManager . sendAndWait ( message ) ; } catch ( ResponseTimeoutException e ) { /* * If the timeout was hit in the previous send-and-wait, then the * socket manager will be expecting the next message that arrives to * be an orphan connected to this command that didn't come back in * time. To get things back in sync, a throwaway command (help) will * be sent. */ socketManager . send ( "help" ) ; return "" ; } }
Send a message and wait for a short period for a response . If no response comes in that time it is assumed that there will be no response from the frontend . This is useful for commands that get a response when there is data available and silence otherwise .