mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 03:02:30 +00:00
feat(net): invoke message handlers from NetClient
This commit is contained in:
parent
5d11881372
commit
1d28c06104
2 changed files with 34 additions and 1 deletions
|
|
@ -209,7 +209,18 @@ int32_t NetClient::HandleConnect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t NetClient::HandleData(uint32_t timeReceived, void* data, int32_t size) {
|
int32_t NetClient::HandleData(uint32_t timeReceived, void* data, int32_t size) {
|
||||||
// TODO
|
// TODO push obj mgr
|
||||||
|
|
||||||
|
CDataStore msg;
|
||||||
|
msg.m_data = static_cast<uint8_t*>(data);
|
||||||
|
msg.m_size = size;
|
||||||
|
msg.m_alloc = -1;
|
||||||
|
msg.m_read = 0;
|
||||||
|
|
||||||
|
this->ProcessMessage(timeReceived, &msg, 0);
|
||||||
|
|
||||||
|
// TODO pop obj mgr
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -259,6 +270,27 @@ void NetClient::PongHandler(WowConnection* conn, CDataStore* msg) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetClient::ProcessMessage(uint32_t timeReceived, CDataStore* msg, int32_t a4) {
|
||||||
|
// TODO s_stats.messagesReceived++
|
||||||
|
|
||||||
|
uint16_t msgId;
|
||||||
|
msg->Get(msgId);
|
||||||
|
|
||||||
|
// TODO virtual function call on NetClient
|
||||||
|
|
||||||
|
if (msgId >= NUM_MSG_TYPES || !this->m_handlers[msgId]) {
|
||||||
|
msg->Reset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_handlers[msgId](
|
||||||
|
this->m_handlerParams[msgId],
|
||||||
|
static_cast<NETMESSAGE>(msgId),
|
||||||
|
timeReceived,
|
||||||
|
msg
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void NetClient::Send(CDataStore* msg) {
|
void NetClient::Send(CDataStore* msg) {
|
||||||
if (this->m_netState != NS_CONNECTED) {
|
if (this->m_netState != NS_CONNECTED) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ class NetClient : public WowConnectionResponse {
|
||||||
int32_t Initialize();
|
int32_t Initialize();
|
||||||
void PollEventQueue();
|
void PollEventQueue();
|
||||||
void PongHandler(WowConnection* conn, CDataStore* msg);
|
void PongHandler(WowConnection* conn, CDataStore* msg);
|
||||||
|
void ProcessMessage(uint32_t timeReceived, CDataStore* msg, int32_t a4);
|
||||||
void Send(CDataStore* msg);
|
void Send(CDataStore* msg);
|
||||||
void SetDelete();
|
void SetDelete();
|
||||||
void SetLoginData(LoginData* loginData);
|
void SetLoginData(LoginData* loginData);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue