mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-02 00:32:45 +03:00
feat(net): push and pop obj mgr in NetClient handlers
This commit is contained in:
parent
eee2986220
commit
b88f694285
@ -1,14 +1,15 @@
|
|||||||
#include "net/connection/NetClient.hpp"
|
#include "net/connection/NetClient.hpp"
|
||||||
#include "net/connection/WowConnection.hpp"
|
|
||||||
#include "glue/CGlueMgr.hpp"
|
#include "glue/CGlueMgr.hpp"
|
||||||
#include <cstdlib>
|
#include "net/connection/WowConnection.hpp"
|
||||||
#include <cstring>
|
#include "object/Client.hpp"
|
||||||
#include <new>
|
|
||||||
#include <common/DataStore.hpp>
|
#include <common/DataStore.hpp>
|
||||||
#include <common/Prop.hpp>
|
#include <common/Prop.hpp>
|
||||||
#include <common/Time.hpp>
|
#include <common/Time.hpp>
|
||||||
#include <storm/Error.hpp>
|
#include <storm/Error.hpp>
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <new>
|
||||||
|
|
||||||
HPROPCONTEXT s_propContext;
|
HPROPCONTEXT s_propContext;
|
||||||
|
|
||||||
@ -245,29 +246,29 @@ int32_t NetClient::HandleCantConnect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t NetClient::HandleConnect() {
|
int32_t NetClient::HandleConnect() {
|
||||||
// TODO push obj mgr
|
this->PushObjMgr();
|
||||||
|
|
||||||
this->m_netState = NS_CONNECTED;
|
this->m_netState = NS_CONNECTED;
|
||||||
|
|
||||||
// TODO pop obj mgr
|
this->PopObjMgr();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 push obj mgr
|
this->PushObjMgr();
|
||||||
|
|
||||||
CDataStore msg = CDataStore(static_cast<uint8_t*>(data), size);
|
CDataStore msg = CDataStore(static_cast<uint8_t*>(data), size);
|
||||||
|
|
||||||
this->ProcessMessage(timeReceived, &msg, 0);
|
this->ProcessMessage(timeReceived, &msg, 0);
|
||||||
|
|
||||||
// TODO pop obj mgr
|
this->PopObjMgr();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t NetClient::HandleDisconnect() {
|
int32_t NetClient::HandleDisconnect() {
|
||||||
// TODO push obj mgr
|
this->PushObjMgr();
|
||||||
|
|
||||||
this->m_netState = NS_INITIALIZED;
|
this->m_netState = NS_INITIALIZED;
|
||||||
|
|
||||||
@ -275,7 +276,7 @@ int32_t NetClient::HandleDisconnect() {
|
|||||||
|
|
||||||
CGlueMgr::NetDisconnectHandler(this, nullptr);
|
CGlueMgr::NetDisconnectHandler(this, nullptr);
|
||||||
|
|
||||||
// TODO pop obj mgr
|
this->PopObjMgr();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -321,6 +322,10 @@ void NetClient::PongHandler(WowConnection* conn, CDataStore* msg) {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetClient::PopObjMgr() {
|
||||||
|
ClntObjMgrPop();
|
||||||
|
}
|
||||||
|
|
||||||
void NetClient::ProcessMessage(uint32_t timeReceived, CDataStore* msg, int32_t a4) {
|
void NetClient::ProcessMessage(uint32_t timeReceived, CDataStore* msg, int32_t a4) {
|
||||||
// TODO s_stats.messagesReceived++
|
// TODO s_stats.messagesReceived++
|
||||||
|
|
||||||
@ -342,6 +347,12 @@ void NetClient::ProcessMessage(uint32_t timeReceived, CDataStore* msg, int32_t a
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetClient::PushObjMgr() {
|
||||||
|
if (this->m_objMgr) {
|
||||||
|
ClntObjMgrPush(this->m_objMgr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NetClient::Send(CDataStore* msg) {
|
void NetClient::Send(CDataStore* msg) {
|
||||||
if (this->m_netState != NS_CONNECTED) {
|
if (this->m_netState != NS_CONNECTED) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class NETEVENTQUEUE {
|
|||||||
|
|
||||||
class NetClient : public WowConnectionResponse {
|
class NetClient : public WowConnectionResponse {
|
||||||
public:
|
public:
|
||||||
// Virtual member functions
|
// Public virtual member functions
|
||||||
virtual void WCMessageReady(WowConnection* conn, uint32_t timeStamp, CDataStore* msg);
|
virtual void WCMessageReady(WowConnection* conn, uint32_t timeStamp, CDataStore* msg);
|
||||||
virtual void WCConnected(WowConnection* conn, WowConnection* inbound, uint32_t timeStamp, const NETCONNADDR* addr);
|
virtual void WCConnected(WowConnection* conn, WowConnection* inbound, uint32_t timeStamp, const NETCONNADDR* addr);
|
||||||
virtual void WCCantConnect(WowConnection* conn, uint32_t timeStamp, NETCONNADDR* addr);
|
virtual void WCCantConnect(WowConnection* conn, uint32_t timeStamp, NETCONNADDR* addr);
|
||||||
@ -61,7 +61,7 @@ class NetClient : public WowConnectionResponse {
|
|||||||
virtual int32_t HandleDisconnect();
|
virtual int32_t HandleDisconnect();
|
||||||
virtual int32_t HandleCantConnect();
|
virtual int32_t HandleCantConnect();
|
||||||
|
|
||||||
// Member functions
|
// Public member functions
|
||||||
void AddRef();
|
void AddRef();
|
||||||
void AuthChallengeHandler(WowConnection* conn, CDataStore* msg);
|
void AuthChallengeHandler(WowConnection* conn, CDataStore* msg);
|
||||||
void Connect(const char* addrStr);
|
void Connect(const char* addrStr);
|
||||||
@ -84,10 +84,10 @@ class NetClient : public WowConnectionResponse {
|
|||||||
void SetObjMgr(ClntObjMgr* objMgr);
|
void SetObjMgr(ClntObjMgr* objMgr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Static variables
|
// Private static variables
|
||||||
static int32_t s_clientCount;
|
static int32_t s_clientCount;
|
||||||
|
|
||||||
// Member variables
|
// Private member variables
|
||||||
LoginData m_loginData;
|
LoginData m_loginData;
|
||||||
NETSTATE m_netState = NS_UNINITIALIZED;
|
NETSTATE m_netState = NS_UNINITIALIZED;
|
||||||
bool m_suspended = false;
|
bool m_suspended = false;
|
||||||
@ -108,6 +108,10 @@ class NetClient : public WowConnectionResponse {
|
|||||||
uint32_t m_connectedTimestamp = 0;
|
uint32_t m_connectedTimestamp = 0;
|
||||||
SCritSect m_pingLock;
|
SCritSect m_pingLock;
|
||||||
ClntObjMgr* m_objMgr = nullptr;
|
ClntObjMgr* m_objMgr = nullptr;
|
||||||
|
|
||||||
|
// Private member functions
|
||||||
|
void PopObjMgr();
|
||||||
|
void PushObjMgr();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user