mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-10-26 22:06:06 +03:00
feat(net): handle connected callback in NetClient
This commit is contained in:
parent
0ca1c8e331
commit
8a3e37ce73
@ -32,7 +32,7 @@ enum EVENTID {
|
|||||||
EVENT_ID_22 = 22,
|
EVENT_ID_22 = 22,
|
||||||
EVENT_ID_PAINT = 23,
|
EVENT_ID_PAINT = 23,
|
||||||
EVENT_ID_24 = 24,
|
EVENT_ID_24 = 24,
|
||||||
EVENT_ID_25 = 25,
|
EVENT_ID_NET_CONNECT = 25,
|
||||||
EVENT_ID_26 = 26,
|
EVENT_ID_26 = 26,
|
||||||
EVENT_ID_27 = 27,
|
EVENT_ID_27 = 27,
|
||||||
EVENT_ID_28 = 28,
|
EVENT_ID_28 = 28,
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <common/Prop.hpp>
|
#include <common/Prop.hpp>
|
||||||
|
#include <common/Time.hpp>
|
||||||
#include <storm/Error.hpp>
|
#include <storm/Error.hpp>
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
|
|
||||||
@ -17,6 +18,10 @@ void InitializePropContext() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NETEVENTQUEUE::AddEvent(EVENTID eventId, void* conn, NetClient* client, const void* data, uint32_t bytes) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
void NetClient::Connect(const char* addrStr) {
|
void NetClient::Connect(const char* addrStr) {
|
||||||
if (this->m_netState != NS_INITIALIZED) {
|
if (this->m_netState != NS_INITIALIZED) {
|
||||||
SErrDisplayAppFatal("Expected (m_netState == NS_INITIALIZED), got %d", this->m_netState);
|
SErrDisplayAppFatal("Expected (m_netState == NS_INITIALIZED), got %d", this->m_netState);
|
||||||
@ -94,7 +99,21 @@ void NetClient::WCCantConnect(WowConnection* conn, uint32_t timeStamp, NETCONNAD
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NetClient::WCConnected(WowConnection* conn, WowConnection* inbound, uint32_t timeStamp, const NETCONNADDR* addr) {
|
void NetClient::WCConnected(WowConnection* conn, WowConnection* inbound, uint32_t timeStamp, const NETCONNADDR* addr) {
|
||||||
|
if (conn != this->m_serverConnection) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_pingLock.Enter();
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
this->m_latencyStart = 0;
|
||||||
|
this->m_latencyEnd = 0;
|
||||||
|
this->m_pingSent = OsGetAsyncTimeMsPrecise();
|
||||||
|
|
||||||
|
this->m_pingLock.Leave();
|
||||||
|
|
||||||
|
this->m_netEventQueue->AddEvent(EVENT_ID_NET_CONNECT, conn, this, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetClient::WCDataReady(WowConnection* conn, uint32_t timeStamp, uint8_t* data, int32_t len) {
|
void NetClient::WCDataReady(WowConnection* conn, uint32_t timeStamp, uint8_t* data, int32_t len) {
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#define NET_CONNECTION_NET_CLIENT_HPP
|
#define NET_CONNECTION_NET_CLIENT_HPP
|
||||||
|
|
||||||
#include "net/connection/WowConnectionResponse.hpp"
|
#include "net/connection/WowConnectionResponse.hpp"
|
||||||
|
#include "event/Event.hpp"
|
||||||
#include "net/Types.hpp"
|
#include "net/Types.hpp"
|
||||||
#include <storm/List.hpp>
|
#include <storm/List.hpp>
|
||||||
#include <storm/Thread.hpp>
|
#include <storm/Thread.hpp>
|
||||||
@ -28,6 +29,7 @@ class NETEVENTQUEUE {
|
|||||||
NETEVENTQUEUE(NetClient* client)
|
NETEVENTQUEUE(NetClient* client)
|
||||||
: m_client(client)
|
: m_client(client)
|
||||||
{};
|
{};
|
||||||
|
void AddEvent(EVENTID eventId, void* conn, NetClient* client, const void* data, uint32_t bytes);
|
||||||
};
|
};
|
||||||
|
|
||||||
class NetClient : public WowConnectionResponse {
|
class NetClient : public WowConnectionResponse {
|
||||||
@ -42,6 +44,12 @@ class NetClient : public WowConnectionResponse {
|
|||||||
void* m_handlerParams[NUM_MSG_TYPES];
|
void* m_handlerParams[NUM_MSG_TYPES];
|
||||||
NETEVENTQUEUE* m_netEventQueue = nullptr;
|
NETEVENTQUEUE* m_netEventQueue = nullptr;
|
||||||
WowConnection* m_serverConnection = nullptr;
|
WowConnection* m_serverConnection = nullptr;
|
||||||
|
uint32_t m_pingSent = 0;
|
||||||
|
uint32_t m_pingSequence = 0;
|
||||||
|
uint32_t m_latency[16];
|
||||||
|
uint32_t m_latencyStart;
|
||||||
|
uint32_t m_latencyEnd;
|
||||||
|
SCritSect m_pingLock;
|
||||||
|
|
||||||
// Virtual member functions
|
// Virtual member functions
|
||||||
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);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user