mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 11:12:29 +00:00
feat(net): handle connected callback in NetClient
This commit is contained in:
parent
0ca1c8e331
commit
8a3e37ce73
3 changed files with 28 additions and 1 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <cstring>
|
||||
#include <new>
|
||||
#include <common/Prop.hpp>
|
||||
#include <common/Time.hpp>
|
||||
#include <storm/Error.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) {
|
||||
if (this->m_netState != NS_INITIALIZED) {
|
||||
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) {
|
||||
if (conn != this->m_serverConnection) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->m_pingLock.Enter();
|
||||
|
||||
// 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) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define NET_CONNECTION_NET_CLIENT_HPP
|
||||
|
||||
#include "net/connection/WowConnectionResponse.hpp"
|
||||
#include "event/Event.hpp"
|
||||
#include "net/Types.hpp"
|
||||
#include <storm/List.hpp>
|
||||
#include <storm/Thread.hpp>
|
||||
|
|
@ -28,6 +29,7 @@ class NETEVENTQUEUE {
|
|||
NETEVENTQUEUE(NetClient* client)
|
||||
: m_client(client)
|
||||
{};
|
||||
void AddEvent(EVENTID eventId, void* conn, NetClient* client, const void* data, uint32_t bytes);
|
||||
};
|
||||
|
||||
class NetClient : public WowConnectionResponse {
|
||||
|
|
@ -42,6 +44,12 @@ class NetClient : public WowConnectionResponse {
|
|||
void* m_handlerParams[NUM_MSG_TYPES];
|
||||
NETEVENTQUEUE* m_netEventQueue = 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 void WCConnected(WowConnection* conn, WowConnection* inbound, uint32_t timeStamp, const NETCONNADDR* addr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue