payserver/server/payserver/ApiListener.h
2019-03-26 11:18:39 +08:00

35 lines
774 B
C++

#pragma once
//game client listener
namespace a8
{
class TcpListener;
}
class ApiListener : public a8::Singleton<ApiListener>
{
private:
ApiListener() {};
friend class a8::Singleton<ApiListener>;
public:
void Init();
void UnInit();
template <typename T>
void SendMsg(unsigned short socket_handle, T& msg)
{
static int msgid = f8::Net_GetMessageId(msg);
f8::Net_SendMsg(tcp_listener_, socket_handle, 0, msgid, msg);
}
void ForwardTargetConnMsg(f8::MsgHdr& hdr);
void SendText(unsigned short sockhandle, const std::string& text);
void ForceCloseClient(unsigned short sockhandle);
void MarkClient(unsigned short sockhandle, bool is_active);
private:
a8::TcpListener *tcp_listener_ = nullptr;
};