40 lines
922 B
C++
40 lines
922 B
C++
#pragma once
|
|
|
|
//game client listener
|
|
namespace a8
|
|
{
|
|
class TcpListener;
|
|
}
|
|
|
|
class GGListener : public a8::Singleton<GGListener>
|
|
{
|
|
private:
|
|
GGListener() {};
|
|
friend class a8::Singleton<GGListener>;
|
|
|
|
public:
|
|
void Init();
|
|
void UnInit();
|
|
|
|
template <typename T>
|
|
void SendProxyMsg(int sockhandle, T& msg)
|
|
{
|
|
static int msgid = f8::Net_GetMessageId(msg);
|
|
f8::Net_SendProxyMsg(tcp_listener_, sockhandle, 0, 0, msgid, msg);
|
|
}
|
|
|
|
template <typename T>
|
|
void SendToClient(int sockhandle, unsigned int seqid, T& msg)
|
|
{
|
|
static int msgid = f8::Net_GetMessageId(msg);
|
|
f8::Net_SendProxyMsg(tcp_listener_, sockhandle, seqid, 0, msgid, msg);
|
|
}
|
|
void SendText(int sockhandle, const std::string& text);
|
|
|
|
void ForceCloseClient(int sockhandle);
|
|
void MarkClient(int sockhandle, bool is_active);
|
|
|
|
private:
|
|
a8::TcpListener *tcp_listener_ = nullptr;
|
|
};
|