示例#1
0
  /**
   * 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...
    }
  }
示例#2
0
 protected void failIfNotConnected() throws RuntimeException {
   if (!bot.isConnected())
     throw new RuntimeException("Trying to send message when no longer connected");
 }