- 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:
parent
8a0390db35
commit
35f6a6665b
|
@ -153,6 +153,7 @@ public:
|
|||
static const char *RANDOMFACTION_SLOTNAME;
|
||||
|
||||
static const char *playerTextureCacheLookupKey;
|
||||
static const char *ircClinetCacheLookupKey;
|
||||
static const char *factionPreviewTextureCacheLookupKey;
|
||||
static const char *characterMenuScreenPositionListCacheLookupKey;
|
||||
static const char *pathCacheLookupKey;
|
||||
|
|
|
@ -50,6 +50,7 @@ const char *GameConstants::folder_path_screenshots = "screens/";
|
|||
const char *GameConstants::OBSERVER_SLOTNAME = "*Observer*";
|
||||
const char *GameConstants::RANDOMFACTION_SLOTNAME = "*Random*";
|
||||
|
||||
const char *GameConstants::ircClinetCacheLookupKey = "ircClientCache";
|
||||
const char *GameConstants::playerTextureCacheLookupKey = "playerTextureCache";
|
||||
const char *GameConstants::factionPreviewTextureCacheLookupKey = "factionPreviewTextureCache";
|
||||
const char *GameConstants::characterMenuScreenPositionListCacheLookupKey = "characterMenuScreenPositionListCache";
|
||||
|
|
|
@ -161,6 +161,21 @@ static void cleanupProcessObjects() {
|
|||
restoreVideoMode(true);
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 IRCCLient Cache SHUTDOWN\n");
|
||||
IRCThread * &ircClient = CacheManager::getCachedItem< IRCThread * >(GameConstants::ircClinetCacheLookupKey);
|
||||
if(ircClient != NULL) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 IRCCLient Cache SHUTDOWN\n");
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
ircClient->setCallbackObj(NULL);
|
||||
ircClient->signalQuit();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
ircClient = NULL;
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#3 IRCCLient Cache SHUTDOWN\n");
|
||||
}
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#4 IRCCLient Cache SHUTDOWN\n");
|
||||
|
||||
cleanupCRCThread();
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "socket.h"
|
||||
#include "masterserver_info.h"
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "cache_manager.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
@ -305,9 +305,22 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||
}
|
||||
|
||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
ircClient = new IRCThread(ircArgs,this);
|
||||
ircClient->setUniqueID(extractFileFromDirectoryPath(__FILE__).c_str());
|
||||
ircClient->start();
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 IRCCLient Cache check\n");
|
||||
IRCThread * &ircThread = CacheManager::getCachedItem< IRCThread * >(GameConstants::ircClinetCacheLookupKey);
|
||||
if(ircThread == NULL) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 IRCCLient Cache check\n");
|
||||
ircThread = new IRCThread(ircArgs,this);
|
||||
ircClient = ircThread;
|
||||
ircClient->setUniqueID(extractFileFromDirectoryPath(__FILE__).c_str());
|
||||
ircClient->start();
|
||||
}
|
||||
else {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#3 IRCCLient Cache check\n");
|
||||
ircClient = ircThread;
|
||||
ircClient->setCallbackObj(this);
|
||||
ircClient->joinChannel();
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
@ -433,8 +446,9 @@ void MenuStateMasterserver::cleanup() {
|
|||
if(ircClient != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
ircClient->leaveChannel();
|
||||
ircClient->setCallbackObj(NULL);
|
||||
ircClient->signalQuit();
|
||||
//ircClient->signalQuit();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
ircClient = NULL;
|
||||
}
|
||||
|
|
|
@ -284,7 +284,6 @@ unsigned int NetworkMessagePing::getPackedSize() {
|
|||
static unsigned int result = 0;
|
||||
if(result == 0) {
|
||||
Data packedData;
|
||||
packedData.pingTime = 0;
|
||||
unsigned char *buf = new unsigned char[sizeof(packedData)*3];
|
||||
result = pack(buf, getPackedMessageFormat(),
|
||||
packedData.messageType,
|
||||
|
@ -383,7 +382,6 @@ unsigned int NetworkMessageReady::getPackedSize() {
|
|||
static unsigned int result = 0;
|
||||
if(result == 0) {
|
||||
Data packedData;
|
||||
packedData.messageType = nmtReady;
|
||||
unsigned char *buf = new unsigned char[sizeof(packedData)*3];
|
||||
result = pack(buf, getPackedMessageFormat(),
|
||||
packedData.messageType,
|
||||
|
@ -1573,7 +1571,6 @@ unsigned int NetworkMessageQuit::getPackedSize() {
|
|||
static unsigned int result = 0;
|
||||
if(result == 0) {
|
||||
Data packedData;
|
||||
packedData.messageType = nmtQuit;
|
||||
unsigned char *buf = new unsigned char[sizeof(packedData)*3];
|
||||
result = pack(buf, getPackedMessageFormat(),
|
||||
packedData.messageType);
|
||||
|
@ -2530,7 +2527,6 @@ unsigned int PlayerIndexMessage::getPackedSize() {
|
|||
static unsigned int result = 0;
|
||||
if(result == 0) {
|
||||
Data packedData;
|
||||
packedData.messageType = nmtPlayerIndexMessage;
|
||||
unsigned char *buf = new unsigned char[sizeof(packedData)*3];
|
||||
result = pack(buf, getPackedMessageFormat(),
|
||||
packedData.messageType,
|
||||
|
@ -2619,7 +2615,6 @@ unsigned int NetworkMessageLoadingStatus::getPackedSize() {
|
|||
static unsigned int result = 0;
|
||||
if(result == 0) {
|
||||
Data packedData;
|
||||
packedData.messageType = nmtLoadingStatusMessage;
|
||||
unsigned char *buf = new unsigned char[sizeof(packedData)*3];
|
||||
result = pack(buf, getPackedMessageFormat(),
|
||||
packedData.messageType,
|
||||
|
@ -2838,7 +2833,6 @@ unsigned int NetworkMessageUnMarkCell::getPackedSize() {
|
|||
static unsigned int result = 0;
|
||||
if(result == 0) {
|
||||
Data packedData;
|
||||
packedData.messageType = nmtUnMarkCell;
|
||||
unsigned char *buf = new unsigned char[sizeof(packedData)*3];
|
||||
result = pack(buf, getPackedMessageFormat(),
|
||||
packedData.messageType,
|
||||
|
@ -2942,7 +2936,6 @@ unsigned int NetworkMessageHighlightCell::getPackedSize() {
|
|||
static unsigned int result = 0;
|
||||
if(result == 0) {
|
||||
Data packedData;
|
||||
packedData.messageType = nmtHighlightCell;
|
||||
unsigned char *buf = new unsigned char[sizeof(packedData)*3];
|
||||
result = pack(buf, getPackedMessageFormat(),
|
||||
packedData.messageType,
|
||||
|
|
|
@ -111,6 +111,10 @@ public:
|
|||
Mutex * getMutexIRCCB() { return &mutexIRCCB; }
|
||||
IRCCallbackInterface * getCallbackObj(bool lockObj=true);
|
||||
void setCallbackObj(IRCCallbackInterface *cb);
|
||||
|
||||
void joinChannel();
|
||||
void leaveChannel();
|
||||
void connectToHost();
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue