feat(net): implement ClientConnection::Disconnect

This commit is contained in:
fallenoak 2025-10-04 21:21:04 -05:00
parent 700db49edc
commit ad8cf56d29
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
4 changed files with 44 additions and 2 deletions

View File

@ -1103,7 +1103,7 @@ enum NETSTATE {
NS_UNINITIALIZED = 0, NS_UNINITIALIZED = 0,
NS_INITIALIZING = 1, NS_INITIALIZING = 1,
NS_INITIALIZED = 2, NS_INITIALIZED = 2,
NS_STATE_3 = 3, NS_DISCONNECTING = 3,
NS_CONNECTING = 4, NS_CONNECTING = 4,
NS_CONNECTED = 5, NS_CONNECTED = 5,
}; };

View File

@ -160,8 +160,14 @@ void ClientConnection::Connect() {
} }
int32_t ClientConnection::Disconnect() { int32_t ClientConnection::Disconnect() {
this->NetClient::Disconnect();
this->m_connected = 0;
// TODO // TODO
return 0; // WardenClient_Destroy();
return 1;
} }
void ClientConnection::GetCharacterList() { void ClientConnection::GetCharacterList() {

View File

@ -165,6 +165,41 @@ void NetClient::DelRef() {
} }
} }
void NetClient::Disconnect() {
auto redirectConnection = this->m_redirectConnection;
if (redirectConnection) {
// TODO
// redirectConnection->SetResponse(0, 0);
redirectConnection->Disconnect();
redirectConnection->Release();
this->m_redirectConnection = nullptr;
}
auto serverConnection = this->m_serverConnection;
if (this->m_netState == NS_CONNECTED) {
this->m_netState = NS_DISCONNECTING;
serverConnection->Disconnect();
} else {
// TODO
// serverConnection->SetResponse(0, 0);
serverConnection->Disconnect();
// TODO
// this->m_netEventQueue->Clear();
serverConnection->Release();
this->m_serverConnection = STORM_NEW(WowConnection)(this, nullptr);
this->m_netState = NS_INITIALIZED;
}
}
void NetClient::EnableEncryption(WowConnection* conn, uint8_t* seed, uint8_t seedLen) { void NetClient::EnableEncryption(WowConnection* conn, uint8_t* seed, uint8_t seedLen) {
conn->SetEncryptionKey( conn->SetEncryptionKey(
this->m_loginData.m_sessionKey, this->m_loginData.m_sessionKey,

View File

@ -64,6 +64,7 @@ class NetClient : public WowConnectionResponse {
void Connect(const char* addrStr); void Connect(const char* addrStr);
int32_t ConnectInternal(const char* host, uint16_t port); int32_t ConnectInternal(const char* host, uint16_t port);
void DelRef(); void DelRef();
void Disconnect();
void EnableEncryption(WowConnection* conn, uint8_t* seed, uint8_t seedLen); void EnableEncryption(WowConnection* conn, uint8_t* seed, uint8_t seedLen);
bool GetDelete(); bool GetDelete();
const LoginData& GetLoginData(); const LoginData& GetLoginData();