mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-13 03:32:28 +00:00
feat(client): implement realm enum callback
This commit is contained in:
parent
22bfe894d2
commit
cd9fe7aee5
9 changed files with 147 additions and 1 deletions
|
|
@ -1169,6 +1169,8 @@ enum NETSTATE {
|
|||
NS_UNINITIALIZED = 0,
|
||||
NS_INITIALIZING = 1,
|
||||
NS_INITIALIZED = 2,
|
||||
NS_STATE_3 = 3,
|
||||
NS_GETTING_REALMS = 4,
|
||||
};
|
||||
|
||||
enum WOW_CONN_STATE {
|
||||
|
|
@ -1188,6 +1190,10 @@ enum WOWC_TYPE {
|
|||
WOWC_TYPE_STREAM = 1,
|
||||
};
|
||||
|
||||
enum WC_ENCRYPT_TYPE {
|
||||
WC_ENCRYPT_0 = 0,
|
||||
};
|
||||
|
||||
enum WC_SEND_RESULT {
|
||||
WC_SEND_SENT = 0,
|
||||
WC_SEND_QUEUED = 1,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
#include "net/connection/NetClient.hpp"
|
||||
#include "net/connection/WowConnection.hpp"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
#include <common/Prop.hpp>
|
||||
#include <storm/Error.hpp>
|
||||
#include <storm/String.hpp>
|
||||
|
||||
HPROPCONTEXT s_propContext;
|
||||
|
||||
|
|
@ -15,6 +17,40 @@ void InitializePropContext() {
|
|||
}
|
||||
}
|
||||
|
||||
void NetClient::Connect(const char* addrStr) {
|
||||
if (this->m_netState != NS_INITIALIZED) {
|
||||
SErrDisplayAppFatal("Expected (m_netState == NS_INITIALIZED), got %d", this->m_netState);
|
||||
}
|
||||
|
||||
uint16_t port = 9090;
|
||||
|
||||
char host[1024];
|
||||
SStrCopy(host, addrStr, sizeof(host));
|
||||
|
||||
auto portDelim = SStrChr(host, ':');
|
||||
if (portDelim) {
|
||||
*portDelim = '\0';
|
||||
port = atoi(portDelim + 1);
|
||||
}
|
||||
|
||||
this->m_serverConnection->SetEncryptionType(WC_ENCRYPT_0);
|
||||
this->m_netState = NS_INITIALIZED;
|
||||
this->ConnectInternal(host, port);
|
||||
}
|
||||
|
||||
int32_t NetClient::ConnectInternal(const char* host, uint16_t port) {
|
||||
if (this->m_netState != NS_INITIALIZED) {
|
||||
SErrDisplayAppFatal("Expected (m_netState == NS_INITIALIZED), got %d", this->m_netState);
|
||||
}
|
||||
|
||||
this->m_netState = NS_GETTING_REALMS;
|
||||
this->m_serverConnection->Connect(host, port, -1);
|
||||
|
||||
// TODO
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t NetClient::Initialize() {
|
||||
STORM_ASSERT(this->m_netState == NS_UNINITIALIZED);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ class NetClient : public WowConnectionResponse {
|
|||
virtual void WCDataReady(WowConnection* conn, uint32_t timeStamp, uint8_t* data, int32_t len);
|
||||
|
||||
// Member functions
|
||||
void Connect(const char* addrStr);
|
||||
int32_t ConnectInternal(const char* host, uint16_t port);
|
||||
int32_t Initialize();
|
||||
void SetLoginData(LoginData* loginData);
|
||||
void SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param);
|
||||
|
|
|
|||
|
|
@ -27,3 +27,7 @@ RealmConnection::RealmConnection(RealmResponse* realmResponse) {
|
|||
|
||||
// TODO
|
||||
}
|
||||
|
||||
void RealmConnection::SetSelectedRealm(uint32_t a2, uint32_t a3, uint32_t a4) {
|
||||
// TODO
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class RealmConnection : public NetClient {
|
|||
|
||||
// Member functions
|
||||
RealmConnection(RealmResponse* realmResponse);
|
||||
void SetSelectedRealm(uint32_t a2, uint32_t a3, uint32_t a4);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -527,6 +527,10 @@ WC_SEND_RESULT WowConnection::SendRaw(uint8_t* data, int32_t len, bool a4) {
|
|||
return WC_SEND_ERROR;
|
||||
}
|
||||
|
||||
void WowConnection::SetEncryptionType(WC_ENCRYPT_TYPE encryptType) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void WowConnection::SetState(WOW_CONN_STATE state) {
|
||||
WOW_CONN_STATE oldState = this->m_connState;
|
||||
this->m_connState = state;
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ class WowConnection {
|
|||
void Release();
|
||||
void ReleaseResponseRef();
|
||||
WC_SEND_RESULT SendRaw(uint8_t* data, int32_t len, bool a4);
|
||||
void SetEncryptionType(WC_ENCRYPT_TYPE encryptType);
|
||||
void SetState(WOW_CONN_STATE state);
|
||||
void SetType(WOWC_TYPE type);
|
||||
void StartConnect();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue