/** Initializes the connection */ @Override public void run() { try { this.setVerbose(true); if (port == null && password == null) { this.connect(this.serverAddress); } else if (port != null && password == null) { this.connect(this.serverAddress, Integer.parseInt(port)); } else { this.connect(this.serverAddress, Integer.parseInt(port), password); } model.connectedServer(this.serverAddress); } catch (NickAlreadyInUseException e) { this.setVerbose(true); String altNick = model.getConfs().getUserData("secondaryNick"); this.setName(altNick); this.nick = altNick; try { if (port == null && password == null) { this.connect(this.serverAddress); } else if (port != null && password == null) { this.connect(this.serverAddress, Integer.parseInt(port)); } else { this.connect(this.serverAddress, Integer.parseInt(port), password); } } catch (Exception ee) { System.out.println("Cant connect!"); model.cantConnect(); } } catch (Exception e) { System.out.println("Cant connect!"); model.cantConnect(); } }
@Override protected void onJoin(String channelName, String joinedNick, String login, String hostname) { Channel c; // We joined a channel if (joinedNick.equals(this.getNick())) { System.out.println("it was us!"); c = new Channel(channelName, this.getServer(), this.model); channels.add(c); model.joinedChannel(c); } else { c = this.getChannel(channelName); if (c != null) { c.userJoins(joinedNick, login, hostname); } } }