45 lines
820 B
C++
45 lines
820 B
C++
#pragma once
|
|
|
|
namespace a8
|
|
{
|
|
class TcpClient;
|
|
}
|
|
|
|
enum VirtualClientState_e
|
|
{
|
|
VCS_Init,
|
|
VCS_Joined,
|
|
};
|
|
|
|
class VirtualClient
|
|
{
|
|
public:
|
|
int instance_id = 0;
|
|
std::string account;
|
|
std::string remote_ip;
|
|
int remote_port = 0;
|
|
|
|
void Init();
|
|
void UnInit();
|
|
void Update();
|
|
|
|
template <typename T>
|
|
void SendMsg(T& msg)
|
|
{
|
|
static int msgid = f8::Net_GetMessageId(msg);
|
|
}
|
|
|
|
private:
|
|
void on_error(a8::TcpClient* sender, int errorId);
|
|
void on_connect(a8::TcpClient* sender);
|
|
void on_disconnect(a8::TcpClient* sender);
|
|
void on_socketread(a8::TcpClient* sender, char* buf, unsigned int len);
|
|
|
|
private:
|
|
VirtualClientState_e state_ = VCS_Init;
|
|
char *recv_buff_ = nullptr;
|
|
unsigned int recv_bufflen_ = 0;
|
|
|
|
a8::TcpClient* tcp_client_ = nullptr;
|
|
};
|