Improve:TcpModule include cleaner.
This commit is contained in:
parent
7cd64c0f03
commit
d9dfbd5f9a
|
@ -13,9 +13,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "ITcpClient.h"
|
||||
#include "ILog.h"
|
||||
#include "TcpModule.h"
|
||||
#include <cstring>
|
||||
#include <sys/types.h>
|
||||
void ITcpClient::Init(void)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "ILog.h"
|
||||
#include "TcpModule.h"
|
||||
#include <cstring>
|
||||
#include <sys/types.h>
|
||||
void ITcpClientAccept::Close(void)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -14,7 +14,15 @@
|
|||
*/
|
||||
#include "TcpClientImpl.h"
|
||||
#include "ILog.h"
|
||||
#include "ITcpClient.h"
|
||||
#include "TcpModule.h"
|
||||
#include "hloop.h"
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
static void on_message(hio_t *io, void *buf, int len)
|
||||
{
|
||||
LogInfo("onmessage: %.*s\n", len, (char *)buf);
|
||||
|
|
|
@ -14,10 +14,13 @@
|
|||
*/
|
||||
#include "TcpModule.h"
|
||||
#include "ILog.h"
|
||||
#include "ITcpClient.h"
|
||||
#include "ITcpServer.h"
|
||||
#include "TcpClientImpl.h"
|
||||
#include "TcpModuleImpl.h"
|
||||
#include "TcpModuleMakePtr.h"
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <sys/types.h>
|
||||
static bool TcpServerObjectCheck(void *object)
|
||||
{
|
||||
if (nullptr == object) {
|
||||
|
|
|
@ -12,29 +12,4 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "TcpModuleImpl.h"
|
||||
#include "ILog.h"
|
||||
#include <cstring>
|
||||
// static const char *TCP_MODULE_NAME = "tcp_module";
|
||||
// const char *GetTcpModuleName(void)
|
||||
// {
|
||||
// return TCP_MODULE_NAME;
|
||||
// }
|
||||
// void *NewTcpModuleImpl(const TcpClientParam &tcpParam)
|
||||
// {
|
||||
// if (nullptr == tcpParam.mIp) {
|
||||
// LogError("Parament error, nullptr == tcpParam.mIp\n");
|
||||
// return nullptr;
|
||||
// }
|
||||
// LogInfo("Create the tcp module object.\n");
|
||||
// TcpServer *impl = (TcpServer *)malloc(sizeof(TcpServer));
|
||||
// TcpServer tmp;
|
||||
// memcpy((void *)impl, (void *)&tmp, sizeof(TcpServer));
|
||||
// impl->mHeader.mCheckName = TCP_MODULE_NAME;
|
||||
// impl->mTcpImpl = std::make_shared<TcpModuleImpl>(tcpParam);
|
||||
// return (void *)(((char *)impl) + sizeof(TcpModuleHeader));
|
||||
// }
|
||||
// void *NewTcpServer(const TcpClientParam &tcpParam)
|
||||
// {
|
||||
// return nullptr;
|
||||
// }
|
||||
// #include "TcpModuleImpl.h"
|
|
@ -14,39 +14,5 @@
|
|||
*/
|
||||
#ifndef TCP_MODULE_IMPL_H
|
||||
#define TCP_MODULE_IMPL_H
|
||||
#include "StatusCode.h"
|
||||
#include "TcpModule.h"
|
||||
#include <memory>
|
||||
// #define TCP_MODULE_INIT_NAME "UART"
|
||||
// typedef struct tcp_module_header
|
||||
// {
|
||||
// const char *mCheckName;
|
||||
// } TcpModuleHeader;
|
||||
// class TcpModuleImpl
|
||||
// {
|
||||
// public:
|
||||
// TcpModuleImpl(const TcpClientParam &uatrInfo);
|
||||
// virtual ~TcpModuleImpl() = default;
|
||||
|
||||
// private:
|
||||
// const StatusCode SetConfig(void);
|
||||
|
||||
// private:
|
||||
// const TcpClientParam mUatrInfo;
|
||||
// int mFd;
|
||||
// };
|
||||
// TODO: There may be a CPU byte alignment bug.
|
||||
// typedef struct tcp_server TcpServer;
|
||||
// typedef struct tcp_server
|
||||
// {
|
||||
// TcpModuleHeader mHeader;
|
||||
// std::shared_ptr<TcpModuleImpl> mTcpImpl;
|
||||
// } TcpServer;
|
||||
// void *NewTcpModuleImpl(const TcpClientParam &tcpParam);
|
||||
// void *NewTcpServer(const TcpClientParam &tcpParam);
|
||||
// static inline TcpServer *TcpModuleImplConvert(void *object)
|
||||
// {
|
||||
// return ((TcpServer *)(((char *)object) - sizeof(TcpModuleHeader)));
|
||||
// }
|
||||
// const char *GetTcpModuleName(void);
|
||||
#endif
|
|
@ -13,9 +13,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "TcpModuleMakePtr.h"
|
||||
#include "ILog.h"
|
||||
#include "ITcpClient.h"
|
||||
#include "ITcpServer.h"
|
||||
#include "TcpClientImpl.h"
|
||||
#include "TcpModule.h"
|
||||
#include "TcpServerImpl.h"
|
||||
#include <memory>
|
||||
std::shared_ptr<TcpModuleMakePtr> &TcpModuleMakePtr::GetInstance(std::shared_ptr<TcpModuleMakePtr> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<TcpModuleMakePtr>();
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
*/
|
||||
#include "TcpServerHandle.h"
|
||||
#include "ILog.h"
|
||||
#include "ITcpServer.h"
|
||||
#include <memory>
|
||||
std::shared_ptr<TcpServerHandle> &TcpServerHandle::GetInstance(std::shared_ptr<TcpServerHandle> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<TcpServerHandle>();
|
||||
|
|
|
@ -14,7 +14,16 @@
|
|||
*/
|
||||
#include "TcpServerImpl.h"
|
||||
#include "ILog.h"
|
||||
#include "TcpServerHandle.h"
|
||||
#include "ITcpServer.h"
|
||||
#include "TcpModule.h"
|
||||
#include "hloop.h"
|
||||
#include "hsocket.h"
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
static void on_close(hio_t *io)
|
||||
{
|
||||
LogInfo("on_close fd=%d error=%d\n", hio_fd(io), hio_error(io));
|
||||
|
@ -172,11 +181,9 @@ std::shared_ptr<ITcpClientAccept> *TcpServerImpl::GetClient(hio_t *io)
|
|||
if (it != mClients.end()) {
|
||||
return it->second;
|
||||
}
|
||||
else {
|
||||
LogError("GetClient failed, client not exit.\n");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
void TcpServerImpl::RemoveClient(hio_t *io)
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(mMutex);
|
||||
|
|
Loading…
Reference in New Issue
Block a user