fireContainerEvent(new ContainerConnectingEvent(this.getID(),
connectID, connectContext));
// Get password via callback in connectContext
String pw = getPasswordFromConnectContext(connectContext);
IRCID tID = (IRCID) connectID;
String host = tID.getHost();
int port = tID.getPort();
String pass = pw;
String nick = tID.getUser();
String user = nick;
this.username = user;
String name = null;
boolean ssl = false;
if (!ssl) {
connection = new IRCConnection(host, new int[] { port }, pass,
nick, user, name);
} else {
connection = new SSLIRCConnection(host, new int[] { port }, pass,
nick, user, name);
}
// connection setup
connection.addIRCEventListener(getIRCEventListener());
connection.setPong(true);
connection.setDaemon(false);
connection.setColors(true);
if (encoding != null)
connection.setEncoding(encoding);
trace(Messages.IRCRootContainer_Connecting_To + targetID);
synchronized (connectLock) {
connectWaiting = true;
connectException = null;
try {
connection.connect();
long timeout = CONNECT_TIMEOUT + System.currentTimeMillis();
while (connectWaiting && (timeout > System.currentTimeMillis())) {
connectLock.wait(2000);
}
if (connectWaiting)
throw new TimeoutException(NLS.bind(
Messages.IRCRootContainer_Connect_Timeout,
tID.getName()), CONNECT_TIMEOUT);
if (connectException != null)
throw connectException;
this.targetID = tID;
fireContainerEvent(new ContainerConnectedEvent(getID(),
this.targetID));