mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-17 05:02:29 +00:00
chore: initial commit
This commit is contained in:
commit
70b00c5c38
965 changed files with 264882 additions and 0 deletions
87
src/net/connection/WowConnection.hpp
Normal file
87
src/net/connection/WowConnection.hpp
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
#ifndef NET_CONNECTION_WOW_CONNECTION_HPP
|
||||
#define NET_CONNECTION_WOW_CONNECTION_HPP
|
||||
|
||||
#include "net/Types.hpp"
|
||||
#include <cstdint>
|
||||
#include <storm/Atomic.hpp>
|
||||
#include <storm/List.hpp>
|
||||
#include <storm/Thread.hpp>
|
||||
|
||||
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#if defined(WHOA_SYSTEM_WIN)
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
class WowConnectionNet;
|
||||
class WowConnectionResponse;
|
||||
|
||||
class WowConnection {
|
||||
public:
|
||||
// Types
|
||||
struct SENDNODE : public TSLinkedNode<SENDNODE> {
|
||||
uint8_t* data;
|
||||
uint32_t size;
|
||||
uint32_t offset;
|
||||
uint32_t datasize;
|
||||
};
|
||||
|
||||
// Static variables
|
||||
static uint64_t s_countTotalBytes;
|
||||
static int32_t s_destroyed;
|
||||
static WowConnectionNet* s_network;
|
||||
static ATOMIC32 s_numWowConnections;
|
||||
static bool (*s_verifyAddr)(const NETADDR*);
|
||||
|
||||
// Static functions
|
||||
static int32_t CreateSocket();
|
||||
static int32_t InitOsNet(bool (*fcn)(const NETADDR*), void (*threadinit)(), int32_t numThreads, bool useEngine);
|
||||
|
||||
// Member variables
|
||||
ATOMIC32 m_refCount;
|
||||
int32_t m_sock;
|
||||
WOW_CONN_STATE m_connState;
|
||||
WowConnectionResponse* m_response;
|
||||
uint32_t m_connectAddress;
|
||||
uint16_t m_connectPort;
|
||||
NETCONNADDR m_peer;
|
||||
SCritSect m_responseLock;
|
||||
int32_t m_responseRef;
|
||||
uintptr_t m_responseRefThread;
|
||||
STORM_LIST(SENDNODE) m_sendList;
|
||||
uint32_t m_serviceFlags;
|
||||
TSLink<WowConnection> m_netlink;
|
||||
SCritSect m_lock;
|
||||
ATOMIC32 m_serviceCount;
|
||||
WOWC_TYPE m_type;
|
||||
|
||||
// Member functions
|
||||
WowConnection(WowConnectionResponse* response, void (*func)(void));
|
||||
WowConnection(int32_t sock, sockaddr_in* addr, WowConnectionResponse* response);
|
||||
void AcquireResponseRef();
|
||||
void AddRef();
|
||||
void CheckAccept();
|
||||
void CheckConnect();
|
||||
void CloseSocket(int32_t sock);
|
||||
bool Connect(char const* address, int32_t retryMs);
|
||||
bool Connect(char const* address, uint16_t port, int32_t retryMs);
|
||||
void Disconnect();
|
||||
void DoDisconnect();
|
||||
void DoExceptions();
|
||||
void DoMessageReads();
|
||||
void DoReads();
|
||||
void DoStreamReads();
|
||||
void DoWrites();
|
||||
WOW_CONN_STATE GetState();
|
||||
void Init(WowConnectionResponse* response, void (*func)(void));
|
||||
void Release();
|
||||
void ReleaseResponseRef();
|
||||
WC_SEND_RESULT SendRaw(uint8_t* data, int32_t len, bool a4);
|
||||
void SetState(WOW_CONN_STATE state);
|
||||
void SetType(WOWC_TYPE type);
|
||||
void StartConnect();
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue