WorldServer now attempts to reconnect to ChatServer

This commit is contained in:
Jonny 2021-12-20 13:50:53 +01:00
parent dfb41c7c40
commit 9d52ee7120

View File

@ -73,6 +73,7 @@ namespace Game {
} }
bool chatDisabled = false; bool chatDisabled = false;
bool chatConnected = false;
bool worldShutdownSequenceStarted = false; bool worldShutdownSequenceStarted = false;
bool worldShutdownSequenceComplete = false; bool worldShutdownSequenceComplete = false;
void WorldShutdownSequence(); void WorldShutdownSequence();
@ -211,6 +212,7 @@ int main(int argc, char** argv) {
Packet* packet = nullptr; Packet* packet = nullptr;
int framesSinceLastFlush = 0; int framesSinceLastFlush = 0;
int framesSinceMasterDisconnect = 0; int framesSinceMasterDisconnect = 0;
int framesSinceChatDisconnect = 0;
int framesSinceLastUsersSave = 0; int framesSinceLastUsersSave = 0;
int framesSinceLastSQLPing = 0; int framesSinceLastSQLPing = 0;
int framesSinceLastUser = 0; int framesSinceLastUser = 0;
@ -318,6 +320,19 @@ int main(int argc, char** argv) {
} }
else framesSinceMasterDisconnect = 0; else framesSinceMasterDisconnect = 0;
// Check if we're still connected to chat:
if (!chatConnected) {
framesSinceChatDisconnect++;
// Attempt to reconnect every 30 seconds.
if (framesSinceChatDisconnect >= 2000) {
framesSinceChatDisconnect = 0;
Game::chatServer->Connect(masterIP.c_str(), chatPort, "3.25 ND1", 8);
}
}
else framesSinceChatDisconnect = 0;
//In world we'd update our other systems here. //In world we'd update our other systems here.
if (zoneID != 0 && deltaTime > 0.0f) { if (zoneID != 0 && deltaTime > 0.0f) {
@ -558,11 +573,15 @@ dLogger * SetupLogger(int zoneID, int instanceID) {
void HandlePacketChat(Packet* packet) { void HandlePacketChat(Packet* packet) {
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) { if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
Game::logger->Log("WorldServer", "Lost our connection to chat.\n"); Game::logger->Log("WorldServer", "Lost our connection to chat.\n");
chatConnected = false;
} }
if (packet->data[0] == ID_CONNECTION_REQUEST_ACCEPTED) { if (packet->data[0] == ID_CONNECTION_REQUEST_ACCEPTED) {
Game::logger->Log("WorldServer", "Established connection to chat\n"); Game::logger->Log("WorldServer", "Established connection to chat\n");
Game::chatSysAddr = packet->systemAddress; Game::chatSysAddr = packet->systemAddress;
chatConnected = true;
} }
if (packet->data[0] == ID_USER_PACKET_ENUM) { if (packet->data[0] == ID_USER_PACKET_ENUM) {