/** * Ajout d'un salon * * @param name */ public void addChannel(String name) { Integer value = channels.get(name); if (value == null) value = 0; ++value; channels.put(name, value); if (value == 1 && connection.isConnected()) connection.doJoin("#" + name); }
/** * Envoi d'un message * * @param channel * @param target * @param message */ public void send(String channel, String target, String message) { if (!connection.isConnected()) { log.log(Level.SEVERE, "IRC connection not connected"); return; } connection.doPrivmsg("#" + channel, target + " " + message); }
/** Constructeur par défaut */ public NetWatcher() { id = buildId(); String server = Configuration.getInstance().getProperty("ircserver"); connection = new IRCNetConnection(server, 6667, id, id); connection.addIRCEventListener(this); connection.setPong(true); connection.start(); }
/** * Suppression d'un salon * * @param name */ public void removeChannel(String name) { Integer value = channels.get(name); if (value == null) return; --value; channels.put(name, value); if (value == 0) { channels.remove(name); if (connection.isConnected()) connection.doPart("#" + name); } }
/** Fermeture du watcher */ public void close() { connection.doQuit(); connection.stop(); }
@Override public void onRegistered() { for (String channel : channels.keySet()) { connection.doJoin("#" + channel); } }