Exemplo n.º 1
0
 public void stop() {
   writeLine("QUIT :Connection closing...");
   reader.kill();
   writer.kill();
   try {
     bWriter.flush();
   } catch (IOException e) {
     manager
         .getPlugin()
         .warn(
             "An error occurred while flushing the output stream for '"
                 + hostname
                 + ":"
                 + port
                 + "'");
   } finally {
     try {
       bWriter.close();
       bReader.close();
     } catch (IOException e) {
       manager
           .getPlugin()
           .warn("An error occured while closing the streams for '" + hostname + ":" + port + "'");
     } finally {
       try {
         connection.close();
       } catch (IOException e) {
         manager
             .getPlugin()
             .warn(
                 "An error occurred while closing the socket for '" + hostname + ":" + port + "'");
       }
     }
   }
 }
Exemplo n.º 2
0
  public Connection(IRCBot bot, String net, String host, int p, String chan) throws IOException {
    manager = bot;
    connection = new Socket(host, p);
    bReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    bWriter = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));

    network = net;
    hostname = host;
    port = p;
    channel = chan;
    key = "";

    reader = new IRCReader(this, "IRCReader: " + host);
    writer = new IRCWriter(this, "IRCWriter: " + host);

    writeLine("NICK " + manager.NICKNAME);
    writeLine(
        "USER "
            + manager.NICKNAME
            + " net.krinsoft.chatsuite "
            + manager.IDENTITY
            + " :"
            + manager.REALNAME);

    writer.start();
    reader.start();
  }