| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #pragma once
- #include <Acceptor.h>
- #include "LNContext.h"
- #include <list>
- #include <mutex>
- #include <thread>
- extern string g_strLocalIp;
- class CLNAcceptor
- : public CAcceptor<CLNContext>
- {
- public:
- CLNAcceptor(CProtocolHandler *);
- virtual ~CLNAcceptor(void);
- friend class CLNHandle;
- virtual CLNContext* make_handler() override;
- BOOL Start();
- void Stop();
- void Lock() { cs.Lock(); }
- void Unlock() { cs.Unlock(); }
- virtual void OnClearContext(); //땍珂헌뇜졍쌈
- void ClearAllContexts(); //헌뇜杰唐졍쌈
- int GetContextNum();
- //꿴冷졍쌈
- CLNContext* FindContext(DWORD_PTR pContext);
- void SendDataAllContexts(uint8_t* data, size_t len);
- private:
- static void ThreadProc(DWORD_PTR);
- std::thread* m_pThread = nullptr;
- bool m_bWork = false;
- time_t m_tmLastKeep = 0;
- time_t m_tmLastZero = 0;
- protected:
- virtual int validate_connection(const ACE_Asynch_Accept::Result& result,
- const ACE_INET_Addr& remote,
- const ACE_INET_Addr& local) override
- {
- auto ip_addr = local.get_ip_address();
- auto strIp =local.get_host_addr();;
- if (ip_addr != 0x7F000001)
- g_strLocalIp = strIp;
- SPDLOG_ERROR("new connection: {}:{} local:{}:{}", remote.get_host_addr(), remote.get_port_number(), strIp, local.get_port_number());
- return 0;
- }
- CCriticalSection cs;
- std::list<CLNContext*> m_lstClientContext;
- CProtocolHandler *m_pHandler = nullptr;
- };
|