no message

This commit is contained in:
zcy 2022-01-05 01:41:58 +08:00
parent 771e4a8684
commit 12b3047006
3 changed files with 12 additions and 0 deletions

View File

@ -7,6 +7,7 @@ TcpServerFrom::TcpServerFrom(ui::Window* hwnd, string url, uint32_t port, TcpSer
m_url = url; m_url = url;
m_port = port; m_port = port;
} }
@ -38,3 +39,9 @@ void TcpServerFrom::Init()
m_server->ConnectionCount()); m_server->ConnectionCount());
m_label_1->SetText(p); m_label_1->SetText(p);
} }
ConnectionLibevent* TcpServerFrom::OnNewConnAccept(bufferevent* ev, uint32_t fd, sockaddr_in* p1)
{
return nullptr;
}

View File

@ -16,6 +16,8 @@ public:
TcpServerFrom(ui::Window* hwnd, string url, uint32_t port, TcpServerLibevent* p); TcpServerFrom(ui::Window* hwnd, string url, uint32_t port, TcpServerLibevent* p);
TcpServerLibevent* ServerP(); TcpServerLibevent* ServerP();
virtual void Init() override; virtual void Init() override;
protected:
ConnectionLibevent* OnNewConnAccept(struct bufferevent* ev, uint32_t fd, struct sockaddr_in* p1);
private: private:
TcpServerLibevent* m_server; TcpServerLibevent* m_server;

View File

@ -62,6 +62,8 @@ class TcpServerLibevent {
}SERVER_STATUS; }SERVER_STATUS;
public: public:
typedef std::function<ConnectionLibevent* (struct bufferevent* ev, uint32_t fd, struct sockaddr_in* p1)> OnAccept; typedef std::function<ConnectionLibevent* (struct bufferevent* ev, uint32_t fd, struct sockaddr_in* p1)> OnAccept;
typedef std::function<void (ConnectionLibevent*)> OnDisconnect;
TcpServerLibevent(int port, string bindip); TcpServerLibevent(int port, string bindip);
SERVER_STATUS Status(); SERVER_STATUS Status();
~TcpServerLibevent(); ~TcpServerLibevent();
@ -85,6 +87,7 @@ private:
thread* m_thread; thread* m_thread;
map<uint32_t, ConnectionLibevent*> m_map_client; map<uint32_t, ConnectionLibevent*> m_map_client;
OnAccept m_handle_accept; OnAccept m_handle_accept;
OnDisconnect m_handle_disconnect;
intptr_t mSocketFD; // 操作系统原生socket intptr_t mSocketFD; // 操作系统原生socket
}; };