/** * Send a request to clementine * * @param message The request as a RequestToThread object * @return true if data was sent, false if not */ public boolean sendRequest(ClementineMessage message) { // Create the protocolbuffer byte[] data = message.getMessage().toByteArray(); try { mOut.writeInt(data.length); mOut.write(data); mOut.flush(); } catch (Exception e) { // Try to reconnect closeSocket(); return false; } return true; }
/** * Disconnect from Clementine * * @param message The RequestDisconnect Object */ public void disconnect(ClementineMessage message) { if (isConnected()) { // Send the disconnect message to clementine byte[] data = message.getMessage().toByteArray(); try { // Now send the data mOut.writeInt(data.length); mOut.write(data); mOut.flush(); closeSocket(); } catch (IOException e) { } } }