- attempt to keep irc connection and just join / leave the irc channel as required to speed up irc in the lobby

This commit is contained in:
Mark Vejvoda
2012-11-10 09:22:28 +00:00
parent 8a0390db35
commit 35f6a6665b
7 changed files with 84 additions and 12 deletions

View File

@@ -706,4 +706,48 @@ void normalizeNick(char *nick) {
}
}
void IRCThread::connectToHost() {
bool connectRequired = false;
if(ircSession == NULL) {
connectRequired = true;
}
else {
int result = irc_is_connected(ircSession);
if(result != 1) {
connectRequired = true;
}
}
if(connectRequired == false) {
if(irc_connect(ircSession, argv[0].c_str(), IRC_SERVER_PORT, 0, this->nick.c_str(), this->username.c_str(), "megaglest")) {
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC Could not connect: %s\n", irc_strerror (irc_errno(ircSession)));
return;
}
}
}
void IRCThread::joinChannel() {
connectToHost();
if(ircSession != NULL) {
IRCThread *ctx = (IRCThread *)irc_get_ctx(ircSession);
if(ctx != NULL) {
eventData.clear();
eventDataDone = false;
hasJoinedChannel = false;
lastNickListUpdate = time(NULL);
irc_cmd_join(ircSession, ctx->getChannel().c_str(), 0);
}
}
}
void IRCThread::leaveChannel() {
if(ircSession != NULL) {
IRCThread *ctx = (IRCThread *)irc_get_ctx(ircSession);
if(ctx != NULL) {
irc_cmd_part(ircSession,ctx->getChannel().c_str());
}
}
}
}}//end namespace