diff --git a/utils/TcpModule/src/ITcpClient.cpp b/utils/TcpModule/src/ITcpClient.cpp index 256ab402..397155e0 100644 --- a/utils/TcpModule/src/ITcpClient.cpp +++ b/utils/TcpModule/src/ITcpClient.cpp @@ -13,9 +13,9 @@ * limitations under the License. */ #include "ITcpClient.h" -#include "ILog.h" #include "TcpModule.h" #include +#include void ITcpClient::Init(void) { } diff --git a/utils/TcpModule/src/ITcpServer.cpp b/utils/TcpModule/src/ITcpServer.cpp index a26c05c7..f34e78e1 100644 --- a/utils/TcpModule/src/ITcpServer.cpp +++ b/utils/TcpModule/src/ITcpServer.cpp @@ -16,6 +16,7 @@ #include "ILog.h" #include "TcpModule.h" #include +#include void ITcpClientAccept::Close(void) { } diff --git a/utils/TcpModule/src/TcpClientImpl.cpp b/utils/TcpModule/src/TcpClientImpl.cpp index 5d76d64e..346ed616 100644 --- a/utils/TcpModule/src/TcpClientImpl.cpp +++ b/utils/TcpModule/src/TcpClientImpl.cpp @@ -14,7 +14,15 @@ */ #include "TcpClientImpl.h" #include "ILog.h" +#include "ITcpClient.h" +#include "TcpModule.h" +#include "hloop.h" +#include #include +#include +#include +#include +#include static void on_message(hio_t *io, void *buf, int len) { LogInfo("onmessage: %.*s\n", len, (char *)buf); diff --git a/utils/TcpModule/src/TcpModule.cpp b/utils/TcpModule/src/TcpModule.cpp index 1cfa9dff..59fd681c 100644 --- a/utils/TcpModule/src/TcpModule.cpp +++ b/utils/TcpModule/src/TcpModule.cpp @@ -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 +#include +#include +#include static bool TcpServerObjectCheck(void *object) { if (nullptr == object) { diff --git a/utils/TcpModule/src/TcpModuleImpl.cpp b/utils/TcpModule/src/TcpModuleImpl.cpp index 08e20a87..6501855a 100644 --- a/utils/TcpModule/src/TcpModuleImpl.cpp +++ b/utils/TcpModule/src/TcpModuleImpl.cpp @@ -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 -// 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(tcpParam); -// return (void *)(((char *)impl) + sizeof(TcpModuleHeader)); -// } -// void *NewTcpServer(const TcpClientParam &tcpParam) -// { -// return nullptr; -// } \ No newline at end of file +// #include "TcpModuleImpl.h" \ No newline at end of file diff --git a/utils/TcpModule/src/TcpModuleImpl.h b/utils/TcpModule/src/TcpModuleImpl.h index 3320ea42..b8530544 100644 --- a/utils/TcpModule/src/TcpModuleImpl.h +++ b/utils/TcpModule/src/TcpModuleImpl.h @@ -14,39 +14,5 @@ */ #ifndef TCP_MODULE_IMPL_H #define TCP_MODULE_IMPL_H -#include "StatusCode.h" -#include "TcpModule.h" #include -// #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 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 \ No newline at end of file diff --git a/utils/TcpModule/src/TcpModuleMakePtr.cpp b/utils/TcpModule/src/TcpModuleMakePtr.cpp index 975d350f..235f4bee 100644 --- a/utils/TcpModule/src/TcpModuleMakePtr.cpp +++ b/utils/TcpModule/src/TcpModuleMakePtr.cpp @@ -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 std::shared_ptr &TcpModuleMakePtr::GetInstance(std::shared_ptr *impl) { static auto instance = std::make_shared(); diff --git a/utils/TcpModule/src/TcpServerHandle.cpp b/utils/TcpModule/src/TcpServerHandle.cpp index 3006dc0f..3928fbae 100644 --- a/utils/TcpModule/src/TcpServerHandle.cpp +++ b/utils/TcpModule/src/TcpServerHandle.cpp @@ -14,6 +14,8 @@ */ #include "TcpServerHandle.h" #include "ILog.h" +#include "ITcpServer.h" +#include std::shared_ptr &TcpServerHandle::GetInstance(std::shared_ptr *impl) { static auto instance = std::make_shared(); diff --git a/utils/TcpModule/src/TcpServerImpl.cpp b/utils/TcpModule/src/TcpServerImpl.cpp index 231a1c26..7455c03d 100644 --- a/utils/TcpModule/src/TcpServerImpl.cpp +++ b/utils/TcpModule/src/TcpServerImpl.cpp @@ -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 +#include +#include +#include +#include +#include static void on_close(hio_t *io) { LogInfo("on_close fd=%d error=%d\n", hio_fd(io), hio_error(io)); @@ -172,10 +181,8 @@ std::shared_ptr *TcpServerImpl::GetClient(hio_t *io) if (it != mClients.end()) { return it->second; } - else { - LogError("GetClient failed, client not exit.\n"); - return nullptr; - } + LogError("GetClient failed, client not exit.\n"); + return nullptr; } void TcpServerImpl::RemoveClient(hio_t *io) {