mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 11:12:29 +00:00
feat(net): implement message ready callback in NetClient
This commit is contained in:
parent
af2a47ae15
commit
8e03d9e5dd
3 changed files with 44 additions and 4 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
#include <common/DataStore.hpp>
|
||||
#include <common/Prop.hpp>
|
||||
#include <common/Time.hpp>
|
||||
#include <storm/Error.hpp>
|
||||
|
|
@ -22,6 +23,10 @@ void NETEVENTQUEUE::AddEvent(EVENTID eventId, void* conn, NetClient* client, con
|
|||
// TODO
|
||||
}
|
||||
|
||||
void NetClient::AuthChallengeHandler(WowConnection* conn, CDataStore* msg) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void NetClient::Connect(const char* addrStr) {
|
||||
if (this->m_netState != NS_INITIALIZED) {
|
||||
SErrDisplayAppFatal("Expected (m_netState == NS_INITIALIZED), got %d", this->m_netState);
|
||||
|
|
@ -85,6 +90,10 @@ int32_t NetClient::Initialize() {
|
|||
return 1;
|
||||
}
|
||||
|
||||
void NetClient::PongHandler(WowConnection* conn, CDataStore* msg) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void NetClient::SetLoginData(LoginData* loginData) {
|
||||
memcpy(&this->m_loginData, loginData, sizeof(this->m_loginData));
|
||||
}
|
||||
|
|
@ -120,6 +129,34 @@ void NetClient::WCDisconnected(WowConnection* conn, uint32_t timeStamp, NETCONNA
|
|||
// TODO
|
||||
}
|
||||
|
||||
void NetClient::WCMessageReady(WowConnection *conn, uint32_t timeStamp, CDataStore* msg) {
|
||||
// TODO
|
||||
void NetClient::WCMessageReady(WowConnection* conn, uint32_t timeStamp, CDataStore* msg) {
|
||||
uint8_t* data;
|
||||
msg->GetDataInSitu(reinterpret_cast<void*&>(data), msg->m_size);
|
||||
|
||||
// TODO increment byte counter
|
||||
// SInterlockedExchangeAdd(this->m_bytesReceived, msg->m_size);
|
||||
|
||||
msg->m_read = 0;
|
||||
|
||||
uint16_t msgId;
|
||||
msg->Get(msgId);
|
||||
|
||||
// TODO SMSG_SUSPEND_COMMS (0x50F)
|
||||
// TODO SMSG_FORCE_SEND_QUEUED_PACKETS (0x511)
|
||||
// TODO SMSG_REDIRECT_CLIENT (0x50D)
|
||||
|
||||
if (msgId == SMSG_PONG) {
|
||||
this->PongHandler(conn, msg);
|
||||
return;
|
||||
} else if (msgId == SMSG_AUTH_CHALLENGE) {
|
||||
this->AuthChallengeHandler(conn, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (conn == this->m_serverConnection && !this->m_suspended) {
|
||||
msg->m_read = msg->m_size;
|
||||
this->m_netEventQueue->AddEvent(EVENT_ID_NET_DATA, conn, this, data, msg->m_size);
|
||||
} else {
|
||||
conn->Disconnect();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue