/** * This method starts the Thread consuming from the outgoing message Queue and sending lines to * the server. */ @Override public void run() { try { while (true) { String line = queue.take(); failIfNotConnected(); if (line != null && bot.isConnected()) sendRawLineNow(line); // Small delay to prevent spamming of the channel Thread.sleep(bot.getMessageDelay()); } } catch (InterruptedException e) { // Just let the method return naturally... } }
protected void failIfNotConnected() throws RuntimeException { if (!bot.isConnected()) throw new RuntimeException("Trying to send message when no longer connected"); }