diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..1716d18 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,62 @@ +name: CodeQL Advanced + +on: + push: + branches: + - 'develop' + paths: + - 'XEngine_Source/**' + - 'XEngine_Release/**' + - '.github/**' + +jobs: + analyze: + runs-on: ubuntu-24.04 + permissions: + security-events: write + packages: read + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: c-cpp + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: 'develop' + + - name: Checkout dependency repository (xengine) + uses: actions/checkout@v4 + with: + repository: libxengine/libxengine + path: libxengine + + - name: sub module checkout (opensource) + run: | + git submodule init + git submodule update + + - name: Set up Dependency Environment + run: | + cd libxengine + chmod +x ./XEngine_LINEnv.sh + sudo ./XEngine_LINEnv.sh -i 3 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + + - name: make + run: | + cd XEngine_Source + make + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml new file mode 100644 index 0000000..279b03f --- /dev/null +++ b/.github/workflows/cppcheck.yml @@ -0,0 +1,35 @@ +name: cpp check workflows + +on: + push: + branches: + - 'develop' + paths: + - 'XEngine_Source/**' + - 'XEngine_Release/**' + - '.github/**' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout main repository code + uses: actions/checkout@v4 + with: + ref: 'develop' + + - name: Create static_analysis directory + run: mkdir -p static_analysis + + - name: Run Cppcheck + run: | + sudo apt-get install -y cppcheck + cppcheck --enable=all --language=c++ --std=c++20 ./XEngine_Source/ --output-file=static_analysis/log.xml --xml + continue-on-error: true + + - name: Upload Cppcheck Results + uses: actions/upload-artifact@v4 + with: + name: cppcheck_results + path: static_analysis/log.xml \ No newline at end of file diff --git a/.github/workflows/linuxbuild.yml b/.github/workflows/linuxbuild.yml deleted file mode 100644 index 2d9766d..0000000 --- a/.github/workflows/linuxbuild.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: ubuntu build workflows - -on: - push: - branches: [ "develop" ] - paths: - - 'XEngine_Source/**' - - 'XEngine_Release/**' - -permissions: - contents: read - -jobs: - build: - strategy: - # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. - fail-fast: false - matrix: - include: - - os: ubuntu-22.04 - #- os: ubuntu-24.04 - runs-on: ${{ matrix.os }} - - steps: - # 检出您的主仓库代码 - - name: Checkout main repository code - uses: actions/checkout@v4 - with: - ref: 'develop' - - # 检出依赖的xengine仓库到指定的xengine目录 - - name: Checkout dependency repository (xengine) - uses: actions/checkout@v4 - with: - repository: libxengine/libxengine - path: libxengine - - - name: sub module checkout (opensource) - run: | - git submodule init - git submodule update - - # 设置依赖库的环境变量 - - name: Set up Dependency Environment Variables - run: | - cd libxengine - chmod 777 * - sudo ./XEngine_LINEnv.sh -i 3 - cd .. - #编译 - - name: make - run: | - cd XEngine_Source - make - make FLAGS=InstallAll - make FLAGS=CleanAll - - make RELEASE=1 - make FLAGS=InstallAll - make FLAGS=CleanAll - cd .. - - name: test - run: | - cd XEngine_Release - ./XEngine_MQServiceApp -t - - - name: Upload folder as artifact with ubuntu - uses: actions/upload-artifact@v4 - with: - name: XEngine_MQServiceApp-x86_64-Ubuntu - path: XEngine_Release/ \ No newline at end of file diff --git a/.github/workflows/macbuild.yml b/.github/workflows/macbuild.yml index f1008f2..dbe2ffc 100644 --- a/.github/workflows/macbuild.yml +++ b/.github/workflows/macbuild.yml @@ -2,13 +2,12 @@ name: macos build workflows on: push: - branches: [ "develop" ] + branches: + - 'develop' paths: - 'XEngine_Source/**' - 'XEngine_Release/**' - -permissions: - contents: read + - '.github/**' jobs: build: @@ -16,6 +15,7 @@ jobs: matrix: include: - os: macos-13 + - os: macos-14 runs-on: ${{ matrix.os }} steps: @@ -24,7 +24,6 @@ jobs: with: ref: 'develop' - # 检出依赖的xengine仓库到指定的xengine目录 - name: Checkout dependency repository (xengine) uses: actions/checkout@v4 with: @@ -39,14 +38,30 @@ jobs: - name: brew install run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - # 设置依赖库的环境变量 - - name: Set up Dependency Environment Variables + - name: Set up Dependency x86_64 Environment + if: matrix.os == 'macos-13' run: | cd libxengine chmod 777 * ./XEngine_LINEnv.sh -i 3 - cd .. - #编译 + - name: Set up Dependency Arm64 Environment + if: matrix.os == 'macos-14' + run: | + cd libxengine + chmod 777 * + ./XEngine_LINEnv.sh -i 0 + + latest_tag=$(git ls-remote --tags --sort="v:refname" https://github.com/libxengine/libxengine.git | awk '{print $2}' | sed 's/refs\/tags\///' | tail -n 1) + + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_Mac_Arm64.zip + unzip ./XEngine_Mac_Arm64.zip -d ./XEngine_Mac_Arm64 + cd XEngine_Mac_Arm64 + + sudo mkdir -p /usr/local/include + sudo mkdir -p /usr/local/lib + sudo cp -rf ./XEngine_Include /usr/local/include + sudo find ./XEngine_Mac -name "*.dylib" -exec cp {} /usr/local/lib \; + - name: make debug run: | cd XEngine_Source @@ -64,8 +79,15 @@ jobs: cd XEngine_Release ./XEngine_MQServiceApp -t - - name: Upload folder as artifact with mac + - name: Upload folder as artifact with mac x64 + if: matrix.os == 'macos-13' uses: actions/upload-artifact@v4 with: name: XEngine_MQServiceApp-x86_64-Mac + path: XEngine_Release/ + - name: Upload folder as artifact with mac arm + if: matrix.os == 'macos-14' + uses: actions/upload-artifact@v4 + with: + name: XEngine_MQServiceApp-Arm64-Mac path: XEngine_Release/ \ No newline at end of file diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml index dea86cb..d2bd79b 100644 --- a/.github/workflows/msbuild.yml +++ b/.github/workflows/msbuild.yml @@ -2,38 +2,34 @@ name: windows build workflows on: push: - branches: [ "develop" ] + branches: + - 'develop' paths: - 'XEngine_Source/**' - 'XEngine_Release/**' - -permissions: - contents: read + - '.github/**' jobs: build: strategy: - # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. fail-fast: false matrix: configuration: [Debug ,Release] platform: [x86 ,x64] - runs-on: windows-latest # 最新的 Windows 环境 + runs-on: windows-latest steps: - # 检出您的主仓库代码 - name: Checkout main repository code uses: actions/checkout@v4 with: ref: 'develop' - # 检出依赖的xengine仓库到指定的xengine目录 - name: Checkout dependency repository (xengine) uses: actions/checkout@v4 with: repository: libxengine/libxengine - path: xengine + path: libxengine - name: sub module checkout (opensource) run: | @@ -41,21 +37,33 @@ jobs: git submodule update shell: pwsh - # 设置依赖库的环境变量 - - name: Set up Dependency Environment Variables + - name: Set up Dependency x86_64 Environment + if: matrix.platform == 'x64' + run: | + echo "XENGINE_INCLUDE=${{ github.workspace }}/libxengine" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "XENGINE_LIB64=${{ github.workspace }}/libxengine/XEngine_Windows" | Out-File -FilePath $env:GITHUB_ENV -Append + shell: pwsh + - name: Set up Dependency x86_32 Environment + if: matrix.platform == 'x86' run: | - echo "XENGINE_INCLUDE=${{ github.workspace }}/xengine" | Out-File -FilePath $env:GITHUB_ENV -Append - echo "XENGINE_LIB32=${{ github.workspace }}/xengine/XEngine_Windows/x86" | Out-File -FilePath $env:GITHUB_ENV -Append - echo "XENGINE_LIB64=${{ github.workspace }}/xengine/XEngine_Windows/x64" | Out-File -FilePath $env:GITHUB_ENV -Append + $response = Invoke-RestMethod -Uri "https://api.github.com/repos/libxengine/libxengine/releases/latest" -Headers @{"Accept"="application/vnd.github.v3+json"} + $latest_tag = $response.tag_name + Write-Host "Latest Tag: $latest_tag" + + $url = "https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_Windows_x86-32.zip" + Invoke-WebRequest -Uri $url -OutFile "XEngine_Windows_x86-32.zip" + Expand-Archive -Path ./XEngine_Windows_x86-32.zip -DestinationPath ./XEngine_Windows -Force + + echo "XENGINE_INCLUDE=${{ github.workspace }}/XEngine_Windows" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "XENGINE_LIB32=${{ github.workspace }}/XEngine_Windows/XEngine_Windows" | Out-File -FilePath $env:GITHUB_ENV -Append shell: pwsh - # 配置 MSBuild 的路径,准备构建 VC++ 项目 - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 - #编译 + - name: Build Solution run: msbuild XEngine_Source/XEngine_MQServiceApp.sln /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} - #测试 + - name: Conditional Step for x86 Release if: matrix.configuration == 'Release' && matrix.platform == 'x86' run: | @@ -66,7 +74,7 @@ jobs: ./VSCopy_x86.bat ./XEngine_MQServiceApp.exe -t shell: pwsh - - name: Conditional Step for x86 Debug + - name: Conditional Step for x64 Release if: matrix.configuration == 'Release' && matrix.platform == 'x64' run: | cp -r XEngine_Source/x64/Release/*.dll XEngine_Release/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a52b626..4edb5e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,10 +16,10 @@ jobs: with: fetch-depth: 0 - - name: Download linuxbuild + - name: Download ubuntubuild uses: dawidd6/action-download-artifact@v6 with: - workflow: linuxbuild.yml + workflow: ubuntubuild.yml workflow_conclusion: success check_artifacts: false skip_unpack: true diff --git a/.github/workflows/ubuntubuild.yml b/.github/workflows/ubuntubuild.yml new file mode 100644 index 0000000..26c558c --- /dev/null +++ b/.github/workflows/ubuntubuild.yml @@ -0,0 +1,88 @@ +name: ubuntu build workflows + +on: + push: + branches: + - 'develop' + paths: + - 'XEngine_Source/**' + - 'XEngine_Release/**' + - '.github/**' + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-22.04 + - os: ubuntu-24.04 + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout main repository code + uses: actions/checkout@v4 + with: + ref: 'develop' + + - name: Checkout dependency repository (xengine) + uses: actions/checkout@v4 + with: + repository: libxengine/libxengine + path: libxengine + + - name: sub module checkout (opensource) + run: | + git submodule init + git submodule update + + - name: Set up Dependency ubuntu24.04 Environment + if: matrix.os == 'ubuntu-24.04' + run: | + cd libxengine + chmod 777 * + sudo ./XEngine_LINEnv.sh -i 3 + - name: Set up Dependency ubuntu22.04 Environment + if: matrix.os == 'ubuntu-22.04' + run: | + cd libxengine + chmod 777 * + sudo ./XEngine_LINEnv.sh -i 0 + + latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_UBuntu_22.04_x86-64.zip + unzip ./XEngine_UBuntu_22.04_x86-64.zip -d ./XEngine_UBuntu_22.04_x86-64 + cd XEngine_UBuntu_22.04_x86-64 + + sudo cp -rf ./XEngine_Include /usr/local/include + sudo find ./XEngine_Linux -name "*.so" -exec cp {} /usr/local/lib \; + sudo ldconfig + + - name: make + run: | + cd XEngine_Source + make + make FLAGS=InstallAll + make FLAGS=CleanAll + + make RELEASE=1 + make FLAGS=InstallAll + make FLAGS=CleanAll + cd .. + - name: test + run: | + cd XEngine_Release + ./XEngine_MQServiceApp -t + + - name: Upload folder as artifact with ubuntu22.04 + if: matrix.os == 'ubuntu-22.04' + uses: actions/upload-artifact@v4 + with: + name: XEngine_MQServiceApp-x86_64-Ubuntu-22.04 + path: XEngine_Release/ + - name: Upload folder as artifact with ubuntu24.04 + if: matrix.os == 'ubuntu-24.04' + uses: actions/upload-artifact@v4 + with: + name: XEngine_MQServiceApp-x86_64-Ubuntu-24.04 + path: XEngine_Release/ \ No newline at end of file diff --git a/CHANGELOG b/CHANGELOG index abf0fa7..328a57e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,39 @@ +XEngine_MQService V3.14.0.1001 + +增加:删除消息协议支持 +增加:用户信息内存数据库支持 +更新:依赖库 +更新:支持xengine v9版本 +更新:网络错误现在使用新的方法定义 +更新:编译器版本更新到C++20,C17 +优化:自动发布支持更多系统 +修改:消息协议定义值 +修改:VS的字符集从ansi改为unicode +修改:回调函数返回数据类型 +修正:内存没有删除老旧消息当修改消息的时候 +修正:字符集乱码问题 +修正:某些时候获取统计信息错误的问题 +修正:内存数据库获取统计信息错误的问题 +修正:总可用时间在内存数据库处理不正确的问题 +修正:内存数据查询不正确的问题 + +added:delete message support +added:user info memory cache supported +update:depend library +update:match xengine v9.x support +update:Network error codes use a new method definition +update:c++ compiler 20 and c compiler 17 +improved:ci workflows release more support +modify:msg protocol define value. +modify:change ansi to unicode character set on vs +modify:callback export type for memory cache +fixed:memory not delete old message when modify message +fixed:Character set garbled problem +fixed:sometimes get left count value is incorrect +fixed:get count is incorrect in data memory cache +fixed:The total available time of memory cache data is not handled correctly +fixed:memory cache query is incorrect +====================================================================================== XEngine_MQService V3.13.0.1001 增加:为DATA消息数据库增加高速缓存支持 diff --git a/README.en.md b/README.en.md index 7ff4846..ba1f938 100644 --- a/README.en.md +++ b/README.en.md @@ -39,7 +39,7 @@ this software support following features ## install #### XEngine Evn -you must install XEngine,need V8.31 or above,install XEngine can be refer to xengine Readme docment +you must install XEngine,need V9 or above,install XEngine can be refer to xengine Readme docment GITEE:https://gitee.com/libxengine/libxengine GITHUB:https://github.com/libxengine/libxengine @@ -64,7 +64,7 @@ Just Run it. #### Linux Linux use Makefile to complie -supproted ubuntu22.04 x64 or RockyLinux9 x64 +supproted ubuntu24.04 x64 or RockyLinux9 x64 ###### complie execute command in XEngine_Source path diff --git a/README.md b/README.md index adc954b..87fdfd5 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@ c c++消息服务 消息中间件 c c++Message Service +## 注意 +编译发布版本将只在github上面发布. + ## 软件架构 此软件基于XEngine开发.采用C/C++作为开发语言 此软件是一款简易的高性能服务,统一的API接口,让用户几乎不需要二次开发就可以直接使用 @@ -38,7 +41,7 @@ c c++Message Service ## 安装教程 #### XEngine环境 -必须安装XEngine,版本需要V8.31或者以上版本,安装XEngine可以参考其Readme文档 +必须安装XEngine,版本需要V9或者以上版本,安装XEngine可以参考其Readme文档 GITEE:https://gitee.com/libxengine/libxengine GITHUB:https://github.com/libxengine/libxengine @@ -64,7 +67,7 @@ git submodule update #### Linux Linux使用Makefile编译 -UBUNTU22.04 x64或者RockyLinux9 x64均可 +UBUNTU24.04 x64或者RockyLinux9 x64均可 在控制台运行 ###### 编译命令 diff --git a/XEngine_Apps/MQCore_HTTPApp/MQCore_HTTPApp.cpp b/XEngine_Apps/MQCore_HTTPApp/MQCore_HTTPApp.cpp index cfae20d..e8ca707 100644 --- a/XEngine_Apps/MQCore_HTTPApp/MQCore_HTTPApp.cpp +++ b/XEngine_Apps/MQCore_HTTPApp/MQCore_HTTPApp.cpp @@ -2,8 +2,8 @@ #include #include #pragma comment(lib,"Ws2_32") -#pragma comment(lib,"x86/XEngine_BaseLib/XEngine_BaseLib") -#pragma comment(lib,"x86/XEngine_Client/XClient_APIHelp") +#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib") +#pragma comment(lib,"XEngine_Client/XClient_APIHelp") #pragma comment(lib,"../../XEngine_Source/Debug/jsoncpp") #endif #include @@ -33,7 +33,7 @@ void MQ_GetUserList() return; } _xtprintf("MQ_GetUserList:%s\n", ptszMsgBody); - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBody); } void MQ_GetOnlineList() { @@ -47,7 +47,7 @@ void MQ_GetOnlineList() return; } _xtprintf("MQ_GetOnlineList:%s\n", ptszMsgBody); - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBody); } void MQ_GetTopicList() { @@ -61,7 +61,7 @@ void MQ_GetTopicList() return; } _xtprintf("MQ_GetTopicList:%s\n", ptszMsgBody); - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBody); } int main() diff --git a/XEngine_Apps/MQCore_HTTPApp/MQCore_HTTPApp.vcxproj b/XEngine_Apps/MQCore_HTTPApp/MQCore_HTTPApp.vcxproj index 5f7b2f9..28e53fe 100644 --- a/XEngine_Apps/MQCore_HTTPApp/MQCore_HTTPApp.vcxproj +++ b/XEngine_Apps/MQCore_HTTPApp/MQCore_HTTPApp.vcxproj @@ -73,13 +73,15 @@ true $(XEngine_Include);$(IncludePath) - $(XEngine_Library);$(LibraryPath) + $(XEngine_Lib32);$(LibraryPath) false true + $(XEngine_Include);$(IncludePath) + $(XEngine_Lib64);$(LibraryPath) false diff --git a/XEngine_Apps/MQCore_TCPApp/MQCore_TCPApp.cpp b/XEngine_Apps/MQCore_TCPApp/MQCore_TCPApp.cpp index 9f3df9a..855630b 100644 --- a/XEngine_Apps/MQCore_TCPApp/MQCore_TCPApp.cpp +++ b/XEngine_Apps/MQCore_TCPApp/MQCore_TCPApp.cpp @@ -2,8 +2,8 @@ #include #include #pragma comment(lib,"Ws2_32.lib") -#pragma comment(lib,"x86/XEngine_BaseLib/XEngine_BaseLib.lib") -#pragma comment(lib,"x86/XEngine_Client/XClient_Socket.lib") +#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib.lib") +#pragma comment(lib,"XEngine_Client/XClient_Socket.lib") #endif #include #include @@ -76,7 +76,7 @@ void MQ_Register() _xtprintf("%d\n", st_ProtocolHdr.wReserve); if (nLen > 0) { - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer); } } void MQ_Authorize() @@ -122,7 +122,7 @@ void MQ_Authorize() _xtprintf("%d\n", st_ProtocolHdr.wReserve); if (nLen > 0) { - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer); } } //获取未读消息 @@ -171,7 +171,7 @@ void MQ_GetUNRead(int nType = 0) { _xtprintf("获取消息队列数据失败,错误码:%d\n", st_ProtocolHdr.wReserve); } - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer); break; } std::this_thread::sleep_for(std::chrono::milliseconds(1)); @@ -345,7 +345,7 @@ void MQ_Post(LPCXSTR lpszMsgBuffer, int nType = 0, int nPubTime = -1, bool bSelf } memset(&st_XMQProtocol, '\0', sizeof(XENGINE_PROTOCOL_XMQ)); memcpy(&st_XMQProtocol, ptszMsgBuffer, sizeof(XENGINE_PROTOCOL_XMQ)); - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer); } void MQ_Get(int nType = 0) { @@ -457,7 +457,7 @@ void MQ_TimePublish() _xtprintf("接受数据失败!\n"); return; } - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer); if (!XClient_TCPSelect_RecvPkt(m_Socket, &ptszMsgBuffer, &nLen, &st_ProtocolHdr, 60)) { @@ -470,7 +470,7 @@ void MQ_TimePublish() memcpy(&st_XMQProtocol, ptszMsgBuffer, sizeof(st_XMQProtocol)); _xtprintf("接受到通知消息,主题:%s,序列:%lld,长度:%d,内容:%s\n", st_XMQProtocol.tszMQKey, st_XMQProtocol.nSerial, st_ProtocolHdr.unPacketSize - sizeof(XENGINE_PROTOCOL_XMQ), ptszMsgBuffer + sizeof(XENGINE_PROTOCOL_XMQ)); - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer); } void MQ_GetNumber() diff --git a/XEngine_Apps/MQCore_TCPApp/MQCore_TCPApp.vcxproj b/XEngine_Apps/MQCore_TCPApp/MQCore_TCPApp.vcxproj index 7ccaf00..f3877e1 100644 --- a/XEngine_Apps/MQCore_TCPApp/MQCore_TCPApp.vcxproj +++ b/XEngine_Apps/MQCore_TCPApp/MQCore_TCPApp.vcxproj @@ -73,13 +73,15 @@ true $(XEngine_Include);$(IncludePath) - $(XEngine_Library);$(LibraryPath) + $(XEngine_Lib32);$(LibraryPath) false true + $(XEngine_Include);$(IncludePath) + $(XEngine_Lib64);$(LibraryPath) false @@ -116,7 +118,7 @@ Level3 true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true diff --git a/XEngine_Apps/MQCore_WSApp/MQCore_WSApp.cpp b/XEngine_Apps/MQCore_WSApp/MQCore_WSApp.cpp index 1444821..0b36765 100644 --- a/XEngine_Apps/MQCore_WSApp/MQCore_WSApp.cpp +++ b/XEngine_Apps/MQCore_WSApp/MQCore_WSApp.cpp @@ -3,10 +3,14 @@ #include #include #pragma comment(lib,"Ws2_32") -#pragma comment(lib,"x86/XEngine_Client/XClient_Socket") -#pragma comment(lib,"x86/XEngine_RfcComponents/RfcComponents_WSProtocol") +#pragma comment(lib,"XEngine_Client/XClient_Socket") +#pragma comment(lib,"XEngine_RfcComponents/RfcComponents_WSProtocol") +#ifdef _WIN64 +#pragma comment(lib,"../../XEngine_Source/x64/Debug/jsoncpp") +#else #pragma comment(lib,"../../XEngine_Source/Debug/jsoncpp") #endif +#endif #include #include #include diff --git a/XEngine_Apps/MQCore_WSApp/MQCore_WSApp.vcxproj b/XEngine_Apps/MQCore_WSApp/MQCore_WSApp.vcxproj index 270b4f5..21d4d52 100644 --- a/XEngine_Apps/MQCore_WSApp/MQCore_WSApp.vcxproj +++ b/XEngine_Apps/MQCore_WSApp/MQCore_WSApp.vcxproj @@ -73,13 +73,15 @@ true $(XEngine_Include);../../XEngine_Source/XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) - $(XEngine_Library);$(LibraryPath) + $(XEngine_Lib32);$(LibraryPath) false true + $(XEngine_Include);../../XEngine_Source/XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Lib64);$(LibraryPath) false diff --git a/XEngine_Apps/VSCopy-x64.bat b/XEngine_Apps/VSCopy-x64.bat new file mode 100644 index 0000000..369235a --- /dev/null +++ b/XEngine_Apps/VSCopy-x64.bat @@ -0,0 +1,7 @@ +copy /y "%XEngine_Lib64%\XEngine_BaseLib\XEngine_BaseLib.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_BaseLib\XEngine_Algorithm.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_Cryption.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_ManagePool.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_RfcComponents\RfcComponents_WSProtocol.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_Client\XClient_APIHelp.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_Client\XClient_Socket.dll" "./" \ No newline at end of file diff --git a/XEngine_Apps/VSCopy-x86.bat b/XEngine_Apps/VSCopy-x86.bat index d8c244e..ece7865 100644 --- a/XEngine_Apps/VSCopy-x86.bat +++ b/XEngine_Apps/VSCopy-x86.bat @@ -1,6 +1,6 @@ copy /y "%XEngine_Lib32%\XEngine_BaseLib\XEngine_BaseLib.dll" "./" copy /y "%XEngine_Lib32%\XEngine_BaseLib\XEngine_Algorithm.dll" "./" -copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_OPenSsl.dll" "./" +copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_Cryption.dll" "./" copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_ManagePool.dll" "./" copy /y "%XEngine_Lib32%\XEngine_RfcComponents\RfcComponents_WSProtocol.dll" "./" copy /y "%XEngine_Lib32%\XEngine_Client\XClient_APIHelp.dll" "./" diff --git a/XEngine_Docment/Docment_en.docx b/XEngine_Docment/Docment_en.docx index 120cb24..51793ca 100644 Binary files a/XEngine_Docment/Docment_en.docx and b/XEngine_Docment/Docment_en.docx differ diff --git a/XEngine_Docment/Docment_zh.docx b/XEngine_Docment/Docment_zh.docx index 2cc9f44..1e15a98 100644 Binary files a/XEngine_Docment/Docment_zh.docx and b/XEngine_Docment/Docment_zh.docx differ diff --git a/XEngine_Release/XEngine_Config/XEngine_Config.json b/XEngine_Release/XEngine_Config/XEngine_Config.json index e271651..67b2e98 100644 --- a/XEngine_Release/XEngine_Config/XEngine_Config.json +++ b/XEngine_Release/XEngine_Config/XEngine_Config.json @@ -22,7 +22,7 @@ "LogLeave":17 }, "XSql":{ - "SQLAddr":"10.0.3.154", + "SQLAddr":"10.0.2.6", "SQLPort":3306, "SQLUser":"root", "SQLPass":"123123aa" @@ -37,8 +37,9 @@ "XMemory":{ "bDataQueryEnable":true, "bDataInsertEnable":true, + "bUserQueryEnable":true, "nTimeLast":3600, - "nTimeStart":0 + "nTimeCount":0 }, "XReport":{ "bEnable":true, diff --git a/XEngine_Release/XEngine_Config/XEngine_VerConfig.json b/XEngine_Release/XEngine_Config/XEngine_VerConfig.json index 09e04b5..83d4fcb 100644 --- a/XEngine_Release/XEngine_Config/XEngine_VerConfig.json +++ b/XEngine_Release/XEngine_Config/XEngine_VerConfig.json @@ -1,5 +1,6 @@ { "XVer":[ + "3.14.0.1001 Build20250120", "3.13.0.1001 Build20241129", "3.12.0.1001 Build20240919", "3.11.0.1001 Build20240517", diff --git a/XEngine_Source/MQCore_ConfigModule/Config_Define.h b/XEngine_Source/MQCore_ConfigModule/Config_Define.h index 9636b4c..29ee591 100644 --- a/XEngine_Source/MQCore_ConfigModule/Config_Define.h +++ b/XEngine_Source/MQCore_ConfigModule/Config_Define.h @@ -59,8 +59,9 @@ typedef struct { bool bDataQueryEnable; bool bDataInsertEnable; + bool bUserQueryEnable; int nTimeLast; - int nTimeStart; + int nTimeCount; }st_XMemory; struct { @@ -70,7 +71,7 @@ typedef struct }st_XReport; struct { - list *pStl_ListStorage; + list *pStl_ListStorage; }st_XVer; }XENGINE_SERVERCONFIG; typedef struct diff --git a/XEngine_Source/MQCore_ConfigModule/Config_Json/Config_Json.cpp b/XEngine_Source/MQCore_ConfigModule/Config_Json/Config_Json.cpp index 7cf026c..e6f4744 100644 --- a/XEngine_Source/MQCore_ConfigModule/Config_Json/Config_Json.cpp +++ b/XEngine_Source/MQCore_ConfigModule/Config_Json/Config_Json.cpp @@ -123,7 +123,7 @@ bool CConfig_Json::Config_Json_File(LPCXSTR lpszConfigFile,XENGINE_SERVERCONFIG _tcsxcpy(pSt_ServerConfig->st_XPass.tszPassRegister, st_JsonXPass["tszPassRegister"].asCString()); _tcsxcpy(pSt_ServerConfig->st_XPass.tszPassUNReg, st_JsonXPass["tszPassUNReg"].asCString()); - if (st_JsonRoot["XMemory"].empty() || (4 != st_JsonRoot["XMemory"].size())) + if (st_JsonRoot["XMemory"].empty() || (5 != st_JsonRoot["XMemory"].size())) { Config_IsErrorOccur = true; Config_dwErrorCode = ERROR_MQ_MODULE_CONFIG_JSON_XMEMORY; @@ -132,8 +132,9 @@ bool CConfig_Json::Config_Json_File(LPCXSTR lpszConfigFile,XENGINE_SERVERCONFIG Json::Value st_JsonXMemory = st_JsonRoot["XMemory"]; pSt_ServerConfig->st_XMemory.bDataQueryEnable = st_JsonXMemory["bDataQueryEnable"].asBool(); pSt_ServerConfig->st_XMemory.bDataInsertEnable = st_JsonXMemory["bDataInsertEnable"].asBool(); + pSt_ServerConfig->st_XMemory.bUserQueryEnable = st_JsonXMemory["bUserQueryEnable"].asBool(); pSt_ServerConfig->st_XMemory.nTimeLast = st_JsonXMemory["nTimeLast"].asInt(); - pSt_ServerConfig->st_XMemory.nTimeStart = st_JsonXMemory["nTimeStart"].asInt(); + pSt_ServerConfig->st_XMemory.nTimeCount = st_JsonXMemory["nTimeCount"].asInt(); if (st_JsonRoot["XReport"].empty() || (3 != st_JsonRoot["XReport"].size())) { @@ -196,7 +197,7 @@ bool CConfig_Json::Config_Json_VersionFile(LPCXSTR lpszConfigFile, XENGINE_SERVE return false; } Json::Value st_JsonXVer = st_JsonRoot["XVer"]; - pSt_ServerConfig->st_XVer.pStl_ListStorage = new list; + pSt_ServerConfig->st_XVer.pStl_ListStorage = new list; for (unsigned int i = 0; i < st_JsonXVer.size(); i++) { diff --git a/XEngine_Source/MQCore_ConfigModule/MQCore_ConfigModule.vcxproj b/XEngine_Source/MQCore_ConfigModule/MQCore_ConfigModule.vcxproj index ef7a5b3..c64a8b5 100644 --- a/XEngine_Source/MQCore_ConfigModule/MQCore_ConfigModule.vcxproj +++ b/XEngine_Source/MQCore_ConfigModule/MQCore_ConfigModule.vcxproj @@ -30,27 +30,27 @@ DynamicLibrary true v143 - MultiByte + Unicode DynamicLibrary false v143 true - MultiByte + Unicode DynamicLibrary true v143 - MultiByte + Unicode DynamicLibrary false v143 true - MultiByte + Unicode @@ -97,6 +97,8 @@ Use pch.h 4819 + stdcpp20 + stdc17 Windows @@ -117,6 +119,9 @@ pch.h MultiThreaded 4819 + stdcpp20 + stdc17 + /utf-8 %(AdditionalOptions) Windows @@ -135,6 +140,8 @@ true Use pch.h + stdcpp20 + stdc17 Windows @@ -155,6 +162,9 @@ pch.h MultiThreaded 4819 + stdcpp20 + stdc17 + /utf-8 %(AdditionalOptions) Windows diff --git a/XEngine_Source/MQCore_ConfigModule/Makefile b/XEngine_Source/MQCore_ConfigModule/Makefile index bdd6bd9..e6ecf33 100644 --- a/XEngine_Source/MQCore_ConfigModule/Makefile +++ b/XEngine_Source/MQCore_ConfigModule/Makefile @@ -1,4 +1,4 @@ -CC = g++ -Wall -std=c++17 -fPIC +CC = g++ -Wall -std=c++20 -fPIC PLATFORM = linux PLATVER = PLATDIR = diff --git a/XEngine_Source/MQCore_ConfigModule/pch.h b/XEngine_Source/MQCore_ConfigModule/pch.h index f12d4d6..bcb0ee5 100644 --- a/XEngine_Source/MQCore_ConfigModule/pch.h +++ b/XEngine_Source/MQCore_ConfigModule/pch.h @@ -24,11 +24,6 @@ using namespace std; #include #include -#ifdef _UNICODE -typedef std::wstring tstring; -#else -typedef std::string tstring; -#endif #include "Config_Define.h" #include "Config_Error.h" /******************************************************************** diff --git a/XEngine_Source/MQCore_DBModule/DBModule_Define.h b/XEngine_Source/MQCore_DBModule/DBModule_Define.h index 7e1377e..f107773 100644 --- a/XEngine_Source/MQCore_DBModule/DBModule_Define.h +++ b/XEngine_Source/MQCore_DBModule/DBModule_Define.h @@ -111,6 +111,20 @@ extern "C" bool DBModule_MQData_Destory(); *********************************************************************/ extern "C" bool DBModule_MQData_Insert(XENGINE_DBMESSAGEQUEUE * pSt_DBInfo); /******************************************************************** +函数名称:DBModule_MQData_Delete +函数功能:删除消息 + 参数.一:pSt_DBInfo + In/Out:In + 类型:数据结构指针 + 可空:N + 意思:输入要删除的消息 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool DBModule_MQData_Delete(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo); +/******************************************************************** 函数名称:DBModule_MQData_Query 函数功能:查询数据 参数.一:pSt_DBInfo @@ -256,7 +270,7 @@ extern "C" bool DBModule_MQData_ShowTable(XCHAR*** pppszTableName, int* pInt_Lis 意思:是否成功 备注: *********************************************************************/ -extern "C" bool DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, int nSerial, int* pInt_Count); +extern "C" bool DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, __int64x nSerial, int* pInt_Count); /************************************************************************* 消息用户导出函数 **************************************************************************/ @@ -268,12 +282,17 @@ extern "C" bool DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, int nSerial, 类型:数据结构指针 可空:N 意思:数据MYSQL数据库连接信息 - 参数.二:fpCall_TimePublish + 参数.二:bMemoryQuery + In/Out:In + 类型:逻辑型 + 可空:N + 意思:是否启用高速缓存查询 + 参数.三:fpCall_TimePublish In/Out:In 类型:回调函数 可空:N 意思:定时消息发布回调函数 - 参数.三:lParam + 参数.四:lParam In/Out:In 类型:无类型指针 可空:Y @@ -283,7 +302,7 @@ extern "C" bool DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, int nSerial, 意思:是否成功 备注: *********************************************************************/ -extern "C" bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam = NULL); +extern "C" bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, bool bMemoryQuery, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam = NULL); /******************************************************************** 函数名称:DBModule_MQUser_Destory 函数功能:销毁数据库管理器 diff --git a/XEngine_Source/MQCore_DBModule/DBModule_MQData/DBModule_MQData.cpp b/XEngine_Source/MQCore_DBModule/DBModule_MQData/DBModule_MQData.cpp index a4d373e..f44c265 100644 --- a/XEngine_Source/MQCore_DBModule/DBModule_MQData/DBModule_MQData.cpp +++ b/XEngine_Source/MQCore_DBModule/DBModule_MQData/DBModule_MQData.cpp @@ -145,6 +145,46 @@ bool CDBModule_MQData::DBModule_MQData_Insert(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo return true; } /******************************************************************** +函数名称:DBModule_MQData_Delete +函数功能:删除消息 + 参数.一:pSt_DBInfo + In/Out:In + 类型:数据结构指针 + 可空:N + 意思:输入要删除的消息 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CDBModule_MQData::DBModule_MQData_Delete(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo) +{ + DBModule_IsErrorOccur = false; + + if (NULL == pSt_DBInfo) + { + DBModule_IsErrorOccur = true; + DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_PARAMENT; + return false; + } + XCHAR tszSQLStatement[10240]; + memset(tszSQLStatement, '\0', sizeof(tszSQLStatement)); + + _xstprintf(tszSQLStatement, _X("DELETE FROM `%s` WHERE tszQueueName = '%s' AND nQueueSerial = '%lld'"), pSt_DBInfo->tszQueueName, pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial); + + if (!DataBase_MySQL_Execute(xhDBSQL, tszSQLStatement)) + { + DBModule_IsErrorOccur = true; + DBModule_dwErrorCode = DataBase_GetLastError(); + return false; + } + if (m_bMemoryQuery) + { + MemoryCache_DBData_DataDelete(pSt_DBInfo); + } + return true; +} +/******************************************************************** 函数名称:DBModule_MQData_Query 函数功能:查询数据 参数.一:pSt_DBInfo @@ -312,6 +352,7 @@ bool CDBModule_MQData::DBModule_MQData_Modify(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo } if (m_bMemoryQuery) { + MemoryCache_DBData_DataDelete(pSt_DBInfo); MemoryCache_DBData_DataInsert(pSt_DBInfo); } return true; @@ -579,7 +620,7 @@ bool CDBModule_MQData::DBModule_MQData_CreateTable(LPCXSTR lpszQueueName) #ifdef _MSC_BUILD int nUTFLen = 0; - BaseLib_OperatorCharset_AnsiToUTF(tszSQLQuery, tszUTFQuery, &nUTFLen); + BaseLib_Charset_AnsiToUTF(tszSQLQuery, tszUTFQuery, &nUTFLen); if (!DataBase_MySQL_Execute(xhDBSQL, tszUTFQuery)) #else if (!DataBase_MySQL_Execute(xhDBSQL, tszSQLQuery)) @@ -725,7 +766,7 @@ bool CDBModule_MQData::DBModule_MQData_ShowTable(XCHAR*** pppszTableName, int* p return false; } *pInt_ListCount = (int)nllLine; - BaseLib_OperatorMemory_Malloc((XPPPMEM)pppszTableName, (int)nllLine, sizeof(XENGINE_DBMESSAGEQUEUE)); + BaseLib_Memory_Malloc((XPPPMEM)pppszTableName, (int)nllLine, sizeof(XENGINE_DBMESSAGEQUEUE)); for (__int64u i = 0; i < nllLine; i++) { XCHAR** pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable); @@ -761,7 +802,7 @@ bool CDBModule_MQData::DBModule_MQData_ShowTable(XCHAR*** pppszTableName, int* p 意思:是否成功 备注: *********************************************************************/ -bool CDBModule_MQData::DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, int nSerial, int* pInt_Count) +bool CDBModule_MQData::DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, __int64x nSerial, int* pInt_Count) { DBModule_IsErrorOccur = false; @@ -779,7 +820,7 @@ bool CDBModule_MQData::DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, int n XCHAR tszSQLStatement[1024]; memset(tszSQLStatement, '\0', sizeof(tszSQLStatement)); - _xstprintf(tszSQLStatement, _X("SELECT COUNT(*) FROM %s WHERE nQueueSerial > %d"), lpszTableName, nSerial); + _xstprintf(tszSQLStatement, _X("SELECT COUNT(*) FROM %s WHERE nQueueSerial > %lld"), lpszTableName, nSerial); if (!DataBase_MySQL_ExecuteQuery(xhDBSQL, &xhTable, tszSQLStatement, &nllLine, &nllRow)) { DBModule_IsErrorOccur = true; diff --git a/XEngine_Source/MQCore_DBModule/DBModule_MQData/DBModule_MQData.h b/XEngine_Source/MQCore_DBModule/DBModule_MQData/DBModule_MQData.h index 18c696b..97f9b4d 100644 --- a/XEngine_Source/MQCore_DBModule/DBModule_MQData/DBModule_MQData.h +++ b/XEngine_Source/MQCore_DBModule/DBModule_MQData/DBModule_MQData.h @@ -20,6 +20,7 @@ class CDBModule_MQData bool DBModule_MQData_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, bool bMemoryQuery = true, bool bMemoryInsert = true); bool DBModule_MQData_Destory(); bool DBModule_MQData_Insert(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo); + bool DBModule_MQData_Delete(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo); bool DBModule_MQData_Query(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo); bool DBModule_MQData_Modify(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo); bool DBModule_MQData_GetSerial(LPCXSTR lpszName, __int64x* pInt_DBCount, XENGINE_DBMESSAGEQUEUE* pSt_DBStart, XENGINE_DBMESSAGEQUEUE* pSt_DBEnd); @@ -27,7 +28,7 @@ class CDBModule_MQData bool DBModule_MQData_DeleteTable(LPCXSTR lpszQueueName); bool DBModule_MQData_ModifyTable(LPCXSTR lpszSrcTable, LPCXSTR lpszDstTable); bool DBModule_MQData_ShowTable(XCHAR*** pppszTableName, int* pInt_ListCount); - bool DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, int nSerial, int* pInt_Count); + bool DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, __int64x nSerial, int* pInt_Count); private: bool m_bMemoryQuery = false; bool m_bMemoryInsert = false; diff --git a/XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.cpp b/XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.cpp index 116d5ea..1ee3bce 100644 --- a/XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.cpp +++ b/XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.cpp @@ -30,12 +30,17 @@ CDBModule_MQUser::~CDBModule_MQUser() 类型:数据结构指针 可空:N 意思:数据MYSQL数据库连接信息 - 参数.二:fpCall_TimePublish + 参数.二:bMemoryQuery + In/Out:In + 类型:逻辑型 + 可空:N + 意思:是否启用高速缓存查询 + 参数.三:fpCall_TimePublish In/Out:In 类型:回调函数 可空:N 意思:定时消息发布回调函数 - 参数.三:lParam + 参数.四:lParam In/Out:In 类型:无类型指针 可空:Y @@ -45,7 +50,7 @@ CDBModule_MQUser::~CDBModule_MQUser() 意思:是否成功 备注: *********************************************************************/ -bool CDBModule_MQUser::DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam /* = NULL */) +bool CDBModule_MQUser::DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, bool bMemoryQuery, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam /* = NULL */) { DBModule_IsErrorOccur = false; @@ -64,6 +69,7 @@ bool CDBModule_MQUser::DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBCo return false; } + m_bMemoryQuery = bMemoryQuery; bIsRun = true; m_lParam = lParam; lpCall_TimePublish = fpCall_TimePublish; @@ -155,6 +161,13 @@ bool CDBModule_MQUser::DBModule_MQUser_UserQuery(XENGINE_PROTOCOL_USERINFO* pSt_ DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_PARAMENT; return false; } + if (m_bMemoryQuery) + { + if (MemoryCache_DBUser_DataQuery(pSt_UserInfo)) + { + return true; + } + } //查询 XNETHANDLE xhTable = 0; __int64u nllLine = 0; @@ -206,6 +219,11 @@ bool CDBModule_MQUser::DBModule_MQUser_UserQuery(XENGINE_PROTOCOL_USERINFO* pSt_ _tcsxcpy(pSt_UserInfo->tszCreateTime, pptszResult[9]); } DataBase_MySQL_FreeResult(xhDBSQL, xhTable); + + if (m_bMemoryQuery) + { + MemoryCache_DBUser_DataInsert(pSt_UserInfo); + } return true; } /******************************************************************** @@ -241,6 +259,10 @@ bool CDBModule_MQUser::DBModule_MQUser_UserDelete(XENGINE_PROTOCOL_USERINFO* pSt DBModule_dwErrorCode = DataBase_GetLastError(); return false; } + if (m_bMemoryQuery) + { + MemoryCache_DBUser_DataDelete(pSt_UserInfo); + } return true; } /******************************************************************** @@ -284,6 +306,12 @@ bool CDBModule_MQUser::DBModule_MQUser_UserUPDate(XENGINE_PROTOCOL_USERINFO* pSt return false; } + if (m_bMemoryQuery) + { + MemoryCache_DBUser_DataDelete(pSt_UserInfo); + MemoryCache_DBUser_DataInsert(pSt_UserInfo); + } + return true; } /******************************************************************** @@ -330,7 +358,7 @@ bool CDBModule_MQUser::DBModule_MQUser_UserList(XENGINE_PROTOCOL_USERINFO*** ppp return false; } *pInt_ListCount = (int)nllLine; - BaseLib_OperatorMemory_Malloc((XPPPMEM)pppSt_UserInfo, (int)nllLine, sizeof(XENGINE_PROTOCOL_USERINFO)); + BaseLib_Memory_Malloc((XPPPMEM)pppSt_UserInfo, (int)nllLine, sizeof(XENGINE_PROTOCOL_USERINFO)); for (__int64u i = 0; i < nllLine; i++) { XCHAR** pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable); @@ -551,7 +579,7 @@ bool CDBModule_MQUser::DBModule_MQUser_KeyList(LPCXSTR lpszUser, LPCXSTR lpszKey return false; } *pInt_ListCount = (int)nllLine; - BaseLib_OperatorMemory_Malloc((XPPPMEM)pppSt_UserKey, (int)nllLine, sizeof(XENGINE_DBUSERKEY)); + BaseLib_Memory_Malloc((XPPPMEM)pppSt_UserKey, (int)nllLine, sizeof(XENGINE_DBUSERKEY)); for (__int64u i = 0; i < nllLine; i++) { XCHAR** pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable); @@ -782,7 +810,7 @@ bool CDBModule_MQUser::DBModule_MQUser_TimeQuery(XENGINE_DBTIMERELEASE*** pppSt_ return false; } *pInt_ListCount = (int)nllLine; - BaseLib_OperatorMemory_Malloc((XPPPMEM)pppSt_DBInfo, *pInt_ListCount, sizeof(XENGINE_DBTIMERELEASE)); + BaseLib_Memory_Malloc((XPPPMEM)pppSt_DBInfo, *pInt_ListCount, sizeof(XENGINE_DBTIMERELEASE)); for (__int64u i = 0; i < nllLine; i++) { XCHAR** pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable); @@ -1141,7 +1169,7 @@ XHTHREAD CALLBACK CDBModule_MQUser::DBModule_MQUser_TimeThread(XPVOID lParam) { pClass_This->lpCall_TimePublish(ppSt_DBInfo[i], pClass_This->m_lParam); } - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_DBInfo, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSt_DBInfo, nListCount); std::this_thread::sleep_for(std::chrono::seconds(1)); } return 0; diff --git a/XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.h b/XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.h index b9df976..51473ce 100644 --- a/XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.h +++ b/XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.h @@ -17,7 +17,7 @@ class CDBModule_MQUser CDBModule_MQUser(); ~CDBModule_MQUser(); public: - bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam = NULL); + bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, bool bMemoryQuery, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam = NULL); bool DBModule_MQUser_Destory(); bool DBModule_MQUser_UserInsert(XENGINE_PROTOCOL_USERINFO* pSt_UserInfo); bool DBModule_MQUser_UserQuery(XENGINE_PROTOCOL_USERINFO* pSt_UserInfo); @@ -51,6 +51,7 @@ class CDBModule_MQUser XPVOID m_lParam; CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH lpCall_TimePublish; private: - bool bIsRun; - XNETHANDLE xhDBSQL; + bool bIsRun = false; + bool m_bMemoryQuery = false; + XNETHANDLE xhDBSQL = 0; }; \ No newline at end of file diff --git a/XEngine_Source/MQCore_DBModule/MQCore_DBModule.def b/XEngine_Source/MQCore_DBModule/MQCore_DBModule.def index eebc8cf..6600c8c 100644 --- a/XEngine_Source/MQCore_DBModule/MQCore_DBModule.def +++ b/XEngine_Source/MQCore_DBModule/MQCore_DBModule.def @@ -6,6 +6,7 @@ EXPORTS DBModule_MQData_Init DBModule_MQData_Destory DBModule_MQData_Insert + DBModule_MQData_Delete DBModule_MQData_Query DBModule_MQData_Modify DBModule_MQData_GetSerial diff --git a/XEngine_Source/MQCore_DBModule/MQCore_DBModule.vcxproj b/XEngine_Source/MQCore_DBModule/MQCore_DBModule.vcxproj index ff6d359..10cd8ac 100644 --- a/XEngine_Source/MQCore_DBModule/MQCore_DBModule.vcxproj +++ b/XEngine_Source/MQCore_DBModule/MQCore_DBModule.vcxproj @@ -30,27 +30,27 @@ DynamicLibrary true v143 - MultiByte + Unicode DynamicLibrary false v143 true - MultiByte + Unicode DynamicLibrary true v143 - MultiByte + Unicode DynamicLibrary false v143 true - MultiByte + Unicode @@ -98,6 +98,8 @@ true Use pch.h + stdcpp20 + stdc17 Windows @@ -116,6 +118,9 @@ true Use pch.h + stdcpp20 + stdc17 + /utf-8 %(AdditionalOptions) Windows @@ -134,6 +139,8 @@ true Use pch.h + stdcpp20 + stdc17 Windows @@ -152,6 +159,9 @@ true Use pch.h + stdcpp20 + stdc17 + /utf-8 %(AdditionalOptions) Windows diff --git a/XEngine_Source/MQCore_DBModule/Makefile b/XEngine_Source/MQCore_DBModule/Makefile index cb608ab..1c3d89f 100644 --- a/XEngine_Source/MQCore_DBModule/Makefile +++ b/XEngine_Source/MQCore_DBModule/Makefile @@ -1,4 +1,4 @@ -CC = g++ -Wall -std=c++17 -fPIC +CC = g++ -Wall -std=c++20 -fPIC PLATFORM = linux PLATVER = PLATDIR = diff --git a/XEngine_Source/MQCore_DBModule/pch.cpp b/XEngine_Source/MQCore_DBModule/pch.cpp index a2707e4..0ff9e09 100644 --- a/XEngine_Source/MQCore_DBModule/pch.cpp +++ b/XEngine_Source/MQCore_DBModule/pch.cpp @@ -43,6 +43,10 @@ extern "C" bool DBModule_MQData_Insert(XENGINE_DBMESSAGEQUEUE * pSt_DBManage) { return m_DBData.DBModule_MQData_Insert(pSt_DBManage); } +extern "C" bool DBModule_MQData_Delete(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo) +{ + return m_DBData.DBModule_MQData_Delete(pSt_DBInfo); +} extern "C" bool DBModule_MQData_Query(XENGINE_DBMESSAGEQUEUE * pSt_DBInfo) { return m_DBData.DBModule_MQData_Query(pSt_DBInfo); @@ -71,16 +75,16 @@ extern "C" bool DBModule_MQData_ShowTable(XCHAR * **pppszTableName, int* pInt_Li { return m_DBData.DBModule_MQData_ShowTable(pppszTableName, pInt_ListCount); } -extern "C" bool DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, int nSerial, int* pInt_Count) +extern "C" bool DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, __int64x nSerial, int* pInt_Count) { return m_DBData.DBModule_MQData_GetLeftCount(lpszTableName, nSerial, pInt_Count); } /************************************************************************* 消息用户导出函数 **************************************************************************/ -extern "C" bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO * pSt_DBConnector, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam) +extern "C" bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO * pSt_DBConnector, bool bMemoryQuery, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam) { - return m_DBUser.DBModule_MQUser_Init(pSt_DBConnector, fpCall_TimePublish, lParam); + return m_DBUser.DBModule_MQUser_Init(pSt_DBConnector, bMemoryQuery, fpCall_TimePublish, lParam); } extern "C" bool DBModule_MQUser_Destory() { diff --git a/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.def b/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.def index a5881ce..516e3d5 100644 --- a/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.def +++ b/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.def @@ -9,4 +9,11 @@ EXPORTS MemoryCache_DBData_DataInsert MemoryCache_DBData_DataQuery MemoryCache_DBData_DataDelete - MemoryCache_DBData_QueueInsert \ No newline at end of file + MemoryCache_DBData_QueueInsert + + MemoryCache_DBUser_Init + MemoryCache_DBUser_SetHandle + MemoryCache_DBUser_Destory + MemoryCache_DBUser_DataInsert + MemoryCache_DBUser_DataQuery + MemoryCache_DBUser_DataDelete \ No newline at end of file diff --git a/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.vcxproj b/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.vcxproj index 49b13b3..534202a 100644 --- a/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.vcxproj +++ b/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.vcxproj @@ -117,6 +117,7 @@ pch.h stdcpp20 stdc17 + /utf-8 %(AdditionalOptions) Windows @@ -157,6 +158,7 @@ pch.h stdcpp20 stdc17 + /utf-8 %(AdditionalOptions) Windows @@ -170,6 +172,7 @@ + @@ -177,6 +180,7 @@ + Create Create diff --git a/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.vcxproj.filters b/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.vcxproj.filters index da7be03..c55a542 100644 --- a/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.vcxproj.filters +++ b/XEngine_Source/MQCore_MemoryCache/MQCore_MemoryCache.vcxproj.filters @@ -19,6 +19,12 @@ {d3182e9a-8f45-4138-b4e2-a793c976d18d} + + {b3468e30-1493-4bfe-88a0-7752163b8820} + + + {9e8d921c-e3ab-4610-a4e9-040dc71a57b4} + @@ -36,6 +42,9 @@ 头文件\MemoryCache_DBData + + 头文件\MemoryCache_DBUser + @@ -47,6 +56,9 @@ 源文件\MemoryCache_DBData + + 源文件\MemoryCache_DBUser + diff --git a/XEngine_Source/MQCore_MemoryCache/Makefile b/XEngine_Source/MQCore_MemoryCache/Makefile index 03b11ce..0bf5aa7 100644 --- a/XEngine_Source/MQCore_MemoryCache/Makefile +++ b/XEngine_Source/MQCore_MemoryCache/Makefile @@ -1,4 +1,4 @@ -CC = g++ -Wall -std=c++17 -fPIC +CC = g++ -Wall -std=c++20 -fPIC PLATFORM = linux PLATVER = PLATDIR = @@ -9,7 +9,7 @@ LOADHDR = -I ./ LOADSO = LIB = -lHelpComponents_DataBase LIBEX = -OBJECTS = MemoryCache_DBData.o pch.o +OBJECTS = MemoryCache_DBData.o MemoryCache_DBUser.o pch.o ifeq ($(RELEASE),1) FLAGS = -c @@ -52,6 +52,8 @@ all:$(OBJECTS) MemoryCache_DBData.o:./MemoryCache_DBData/MemoryCache_DBData.cpp $(CC) $(DEBUG) $(FLAGS) $(PLATVER) $(LOADHDR) ./MemoryCache_DBData/MemoryCache_DBData.cpp +MemoryCache_DBUser.o:./MemoryCache_DBUser/MemoryCache_DBUser.cpp + $(CC) $(DEBUG) $(FLAGS) $(PLATVER) $(LOADHDR) ./MemoryCache_DBUser/MemoryCache_DBUser.cpp pch.o:./pch.cpp $(CC) $(DEBUG) $(FLAGS) $(PLATVER) $(LOADHDR) ./pch.cpp diff --git a/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBData/MemoryCache_DBData.cpp b/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBData/MemoryCache_DBData.cpp index 772a61f..3a59ddd 100644 --- a/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBData/MemoryCache_DBData.cpp +++ b/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBData/MemoryCache_DBData.cpp @@ -29,24 +29,24 @@ CMemoryCache_DBData::~CMemoryCache_DBData() 类型:整数型 可空:N 意思:允许的最后更新时间存在秒数 - 参数.二:nTimeStart + 参数.二:nTimeCount In/Out:In 类型:整数型 可空:N - 意思:允许的最大保留时间 + 意思:允许的最大保留时间.将不关心是否使用,0不启用 返回值 类型:逻辑型 意思:是否成功 备注: *********************************************************************/ -bool CMemoryCache_DBData::MemoryCache_DBData_Init(int nTimeLast, int nTimeStart, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam /* = NULL */) +bool CMemoryCache_DBData::MemoryCache_DBData_Init(int nTimeLast, int nTimeCount, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam /* = NULL */) { MemoryCache_IsErrorOccur = false; bIsRun = true; m_nTimeLast = nTimeLast; - m_nTimeStart = nTimeStart; + m_nTimeCount = nTimeCount; m_lParam = lParam; lpCall_MemoryCache = fpCall_MemoryCache; @@ -136,7 +136,7 @@ bool CMemoryCache_DBData::MemoryCache_DBData_DataInsert(XENGINE_DBMESSAGEQUEUE* MEMORYCACHE_DBINFO st_DBInfo = {}; - st_DBInfo.nTimeStart = time(NULL); + st_DBInfo.nTimeLast = st_DBInfo.nTimeStart = time(NULL); st_DBInfo.st_DBMessageInfo = *pSt_DBMessageInfo; std::tuple<__int64x, std::string> stl_Key(pSt_DBMessageInfo->nQueueSerial, pSt_DBMessageInfo->tszQueueName); @@ -201,7 +201,7 @@ bool CMemoryCache_DBData::MemoryCache_DBData_DataQuery(XENGINE_DBMESSAGEQUEUE* p In/Out:In 类型:数据结构指针 可空:N - 意思:输入要操作的信息 + 意思:输入要操作的信息` 返回值 类型:逻辑型 意思:是否成功 @@ -297,11 +297,11 @@ XHTHREAD CALLBACK CMemoryCache_DBData::DBModule_MQUser_TimeThread(XPVOID lParam) pClass_This->st_LockerQuery.lock_shared(); for (auto stl_MapIterator = pClass_This->stl_MapQuery.begin(); stl_MapIterator != pClass_This->stl_MapQuery.end(); stl_MapIterator++) { - if (stl_MapIterator->second.nTimeLast > (nTimeEnd - pClass_This->m_nTimeLast)) + if ((nTimeEnd - stl_MapIterator->second.nTimeLast) > pClass_This->m_nTimeLast) { stl_ListDelete.push_back(stl_MapIterator->second.st_DBMessageInfo); } - else if (pClass_This->m_nTimeStart > 0 && (nTimeEnd - pClass_This->m_nTimeStart)) + else if (pClass_This->m_nTimeCount > 0 && ((nTimeEnd - stl_MapIterator->second.nTimeLast) > pClass_This->m_nTimeCount)) { stl_ListDelete.push_back(stl_MapIterator->second.st_DBMessageInfo); } @@ -313,13 +313,14 @@ XHTHREAD CALLBACK CMemoryCache_DBData::DBModule_MQUser_TimeThread(XPVOID lParam) XENGINE_DBMESSAGEQUEUE st_DBMessage = *stl_ListIterator; if (pClass_This->MemoryCache_DBData_DataDelete(&st_DBMessage)) { - pClass_This->lpCall_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_QUERY, true, pClass_This->stl_ListInsert.size(), &st_DBMessage, pClass_This->m_lParam); + pClass_This->lpCall_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_QUERY, true, pClass_This->stl_MapQuery.size(), (XPVOID)&st_DBMessage, pClass_This->m_lParam); } else { - pClass_This->lpCall_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_QUERY, false, pClass_This->stl_ListInsert.size(), &st_DBMessage, pClass_This->m_lParam); + pClass_This->lpCall_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_QUERY, false, pClass_This->stl_MapQuery.size(), (XPVOID)&st_DBMessage, pClass_This->m_lParam); } } + stl_ListDelete.clear(); std::this_thread::sleep_for(std::chrono::seconds(1)); } return 0; @@ -339,11 +340,11 @@ XHTHREAD CALLBACK CMemoryCache_DBData::DBModule_MQUser_InsertThread(XPVOID lPara if (DataBase_MySQL_Execute(pClass_This->m_xhDBSQL, st_DBInsert.m_StrSQL.c_str())) { - pClass_This->lpCall_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_INSERT, true, pClass_This->stl_ListInsert.size(), &st_DBInsert.st_DBMessageInfo, pClass_This->m_lParam); + pClass_This->lpCall_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_INSERT, true, pClass_This->stl_ListInsert.size(), (XPVOID)&st_DBInsert.st_DBMessageInfo, pClass_This->m_lParam); } else { - pClass_This->lpCall_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_INSERT, false, pClass_This->stl_ListInsert.size(), &st_DBInsert.st_DBMessageInfo, pClass_This->m_lParam); + pClass_This->lpCall_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_INSERT, false, pClass_This->stl_ListInsert.size(), (XPVOID)&st_DBInsert.st_DBMessageInfo, pClass_This->m_lParam); } } std::this_thread::sleep_for(std::chrono::milliseconds(1)); diff --git a/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBData/MemoryCache_DBData.h b/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBData/MemoryCache_DBData.h index 09ecd58..6cb9638 100644 --- a/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBData/MemoryCache_DBData.h +++ b/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBData/MemoryCache_DBData.h @@ -42,7 +42,7 @@ class CMemoryCache_DBData CMemoryCache_DBData(); ~CMemoryCache_DBData(); public: - bool MemoryCache_DBData_Init(int nTimeLast, int nTimeStart, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam = NULL); + bool MemoryCache_DBData_Init(int nTimeLast, int nTimeCount, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam = NULL); bool MemoryCache_DBData_SetHandle(XNETHANDLE xhDBSQL); bool MemoryCache_DBData_Destory(); public: @@ -57,7 +57,7 @@ class CMemoryCache_DBData private: bool bIsRun = false; int m_nTimeLast = 0; - int m_nTimeStart = 0; + int m_nTimeCount = 0; XNETHANDLE m_xhDBSQL = 0; XPVOID m_lParam; diff --git a/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBUser/MemoryCache_DBUser.cpp b/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBUser/MemoryCache_DBUser.cpp new file mode 100644 index 0000000..52aae56 --- /dev/null +++ b/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBUser/MemoryCache_DBUser.cpp @@ -0,0 +1,255 @@ +#include "pch.h" +#include "MemoryCache_DBUser.h" +/******************************************************************** +// Created: 2025/01/17 10:09:09 +// File Name: D:\XEngine_MQService\XEngine_Source\MQCore_MemoryCache\MemoryCache_DBUser\MemoryCache_DBUser.cpp +// File Path: D:\XEngine_MQService\XEngine_Source\MQCore_MemoryCache\MemoryCache_DBUser +// File Base: MemoryCache_DBUser +// File Ext: cpp +// Project: XEngine(网络通信引擎) +// Author: qyt +// Purpose: 数据库高速缓存 +// History: +*********************************************************************/ +CMemoryCache_DBUser::CMemoryCache_DBUser() +{ +} +CMemoryCache_DBUser::~CMemoryCache_DBUser() +{ + +} +////////////////////////////////////////////////////////////////////////// +// 公有函数 +////////////////////////////////////////////////////////////////////////// +/******************************************************************** +函数名称:MemoryCache_DBUser_Init +函数功能:初始化高速缓存管理器 + 参数.一:nTimeLast + In/Out:In + 类型:整数型 + 可空:N + 意思:允许的最后更新时间存在秒数 + 参数.二:nTimeCount + In/Out:In + 类型:整数型 + 可空:N + 意思:允许的最大保留时间.将不关心是否使用,0不启用 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CMemoryCache_DBUser::MemoryCache_DBUser_Init(int nTimeLast, int nTimeCount, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam /* = NULL */) +{ + MemoryCache_IsErrorOccur = false; + + bIsRun = true; + + m_nTimeLast = nTimeLast; + m_nTimeCount = nTimeCount; + m_lParam = lParam; + lpCall_MemoryCache = fpCall_MemoryCache; + + pSTDThread_Query = std::make_unique(DBModule_MQUser_TimeThread, this); + if (NULL == pSTDThread_Query) + { + MemoryCache_IsErrorOccur = true; + MemoryCache_dwErrorCode = ERROR_XENGINE_MQCORE_MEMORYCACHE_DBDATA_THREAD; + return false; + } + return true; +} +/******************************************************************** +函数名称:MemoryCache_DBUser_SetHandle +函数功能:设置句柄 + 参数.一:xhDBSQL + In/Out:In + 类型:句柄 + 可空:N + 意思:数据库句柄 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CMemoryCache_DBUser::MemoryCache_DBUser_SetHandle(XNETHANDLE xhDBSQL) +{ + MemoryCache_IsErrorOccur = false; + + m_xhDBSQL = xhDBSQL; + + return true; +} +/******************************************************************** +函数名称:MemoryCache_DBUser_Destory +函数功能:销毁高速缓存管理器 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CMemoryCache_DBUser::MemoryCache_DBUser_Destory() +{ + MemoryCache_IsErrorOccur = false; + + bIsRun = false; + if (NULL != pSTDThread_Query) + { + pSTDThread_Query->join(); + } + return true; +} +/******************************************************************** +函数名称:MemoryCache_DBUser_DataInsert +函数功能:插入一条数据到高速缓存 + 参数.一:pSt_DBUserInfo + In/Out:In + 类型:数据结构指针 + 可空:N + 意思:输入要插入的信息 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CMemoryCache_DBUser::MemoryCache_DBUser_DataInsert(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo) +{ + MemoryCache_IsErrorOccur = false; + + if (NULL == pSt_DBUserInfo) + { + MemoryCache_IsErrorOccur = true; + MemoryCache_dwErrorCode = ERROR_XENGINE_MQCORE_MEMORYCACHE_DBDATA_PARAMENT; + return false; + } + + st_LockerQuery.lock(); + auto stl_MapIterator = stl_MapQuery.find(pSt_DBUserInfo->tszUserName); + if (stl_MapIterator == stl_MapQuery.end()) + { + MEMORYCACHE_DBUSER st_DBInfo = {}; + + st_DBInfo.nTimeLast = st_DBInfo.nTimeStart = time(NULL); + st_DBInfo.st_DBUserInfo = *pSt_DBUserInfo; + stl_MapQuery[pSt_DBUserInfo->tszUserName] = st_DBInfo; + } + else + { + stl_MapIterator->second.st_DBUserInfo = *pSt_DBUserInfo; + } + st_LockerQuery.unlock(); + return true; +} +/******************************************************************** +函数名称:MemoryCache_DBUser_DataQuery +函数功能:查询高速缓存 + 参数.一:pSt_DBUserInfo + In/Out:In + 类型:数据结构指针 + 可空:N + 意思:输入要查询的信息 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CMemoryCache_DBUser::MemoryCache_DBUser_DataQuery(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo) +{ + MemoryCache_IsErrorOccur = false; + + if (NULL == pSt_DBUserInfo) + { + MemoryCache_IsErrorOccur = true; + MemoryCache_dwErrorCode = ERROR_XENGINE_MQCORE_MEMORYCACHE_DBDATA_PARAMENT; + return false; + } + + st_LockerQuery.lock_shared(); + auto stl_MapIterator = stl_MapQuery.find(pSt_DBUserInfo->tszUserName); + if (stl_MapIterator == stl_MapQuery.end()) + { + MemoryCache_IsErrorOccur = true; + MemoryCache_dwErrorCode = ERROR_XENGINE_MQCORE_MEMORYCACHE_DBDATA_NOTFOUND; + st_LockerQuery.unlock_shared(); + return false; + } + stl_MapIterator->second.nTimeLast = time(NULL); + *pSt_DBUserInfo = stl_MapIterator->second.st_DBUserInfo; + st_LockerQuery.unlock_shared(); + return true; +} +/******************************************************************** +函数名称:MemoryCache_DBUser_DataDelete +函数功能:删除高速缓存 + 参数.一:pSt_DBUserInfo + In/Out:In + 类型:数据结构指针 + 可空:N + 意思:输入要操作的信息 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CMemoryCache_DBUser::MemoryCache_DBUser_DataDelete(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo) +{ + MemoryCache_IsErrorOccur = false; + + if (NULL == pSt_DBUserInfo) + { + MemoryCache_IsErrorOccur = true; + MemoryCache_dwErrorCode = ERROR_XENGINE_MQCORE_MEMORYCACHE_DBDATA_PARAMENT; + return false; + } + + st_LockerQuery.lock(); + auto stl_MapIterator = stl_MapQuery.find(pSt_DBUserInfo->tszUserName); + if (stl_MapIterator != stl_MapQuery.end()) + { + stl_MapQuery.erase(stl_MapIterator); + } + st_LockerQuery.unlock(); + return true; +} +////////////////////////////////////////////////////////////////////////// +// 线程函数 +////////////////////////////////////////////////////////////////////////// +XHTHREAD CALLBACK CMemoryCache_DBUser::DBModule_MQUser_TimeThread(XPVOID lParam) +{ + CMemoryCache_DBUser* pClass_This = (CMemoryCache_DBUser*)lParam; + + std::list stl_ListDelete; + while (pClass_This->bIsRun) + { + time_t nTimeEnd = time(NULL); + pClass_This->st_LockerQuery.lock_shared(); + for (auto stl_MapIterator = pClass_This->stl_MapQuery.begin(); stl_MapIterator != pClass_This->stl_MapQuery.end(); stl_MapIterator++) + { + if ((nTimeEnd - stl_MapIterator->second.nTimeLast) > pClass_This->m_nTimeLast) + { + stl_ListDelete.push_back(stl_MapIterator->second.st_DBUserInfo); + } + else if (pClass_This->m_nTimeCount > 0 && ((nTimeEnd - stl_MapIterator->second.nTimeLast) > pClass_This->m_nTimeCount)) + { + stl_ListDelete.push_back(stl_MapIterator->second.st_DBUserInfo); + } + } + pClass_This->st_LockerQuery.unlock_shared(); + + for (auto stl_ListIterator = stl_ListDelete.begin(); stl_ListIterator != stl_ListDelete.end(); stl_ListIterator++) + { + XENGINE_PROTOCOL_USERINFO st_DBUser = *stl_ListIterator; + if (pClass_This->MemoryCache_DBUser_DataDelete(&st_DBUser)) + { + pClass_This->lpCall_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE_USER_QUERY, true, pClass_This->stl_MapQuery.size(), (XPVOID)&st_DBUser, pClass_This->m_lParam); + } + else + { + pClass_This->lpCall_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE_USER_QUERY, false, pClass_This->stl_MapQuery.size(), (XPVOID)&st_DBUser, pClass_This->m_lParam); + } + } + stl_ListDelete.clear(); + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + return 0; +} \ No newline at end of file diff --git a/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBUser/MemoryCache_DBUser.h b/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBUser/MemoryCache_DBUser.h new file mode 100644 index 0000000..171dc88 --- /dev/null +++ b/XEngine_Source/MQCore_MemoryCache/MemoryCache_DBUser/MemoryCache_DBUser.h @@ -0,0 +1,48 @@ +#pragma once +/******************************************************************** +// Created: 2025/01/17 10:08:29 +// File Name: D:\XEngine_MQService\XEngine_Source\MQCore_MemoryCache\MemoryCache_DBUser\MemoryCache_DBUser.h +// File Path: D:\XEngine_MQService\XEngine_Source\MQCore_MemoryCache\MemoryCache_DBUser +// File Base: MemoryCache_DBUser +// File Ext: h +// Project: XEngine(网络通信引擎) +// Author: qyt +// Purpose: 数据库高速缓存 +// History: +*********************************************************************/ +typedef struct +{ + XENGINE_PROTOCOL_USERINFO st_DBUserInfo; + time_t nTimeStart; + time_t nTimeLast; +}MEMORYCACHE_DBUSER; + +class CMemoryCache_DBUser +{ +public: + CMemoryCache_DBUser(); + ~CMemoryCache_DBUser(); +public: + bool MemoryCache_DBUser_Init(int nTimeLast, int nTimeCount, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam = NULL); + bool MemoryCache_DBUser_SetHandle(XNETHANDLE xhDBSQL); + bool MemoryCache_DBUser_Destory(); +public: + bool MemoryCache_DBUser_DataInsert(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo); + bool MemoryCache_DBUser_DataQuery(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo); + bool MemoryCache_DBUser_DataDelete(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo); +protected: + static XHTHREAD CALLBACK DBModule_MQUser_TimeThread(XPVOID lParam); +private: + bool bIsRun = false; + int m_nTimeLast = 0; + int m_nTimeCount = 0; + XNETHANDLE m_xhDBSQL = 0; + + XPVOID m_lParam; + CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE lpCall_MemoryCache; +private: + std::shared_mutex st_LockerQuery; + std::unique_ptr pSTDThread_Query; +private: + std::unordered_map stl_MapQuery; +}; \ No newline at end of file diff --git a/XEngine_Source/MQCore_MemoryCache/MemoryCache_Define.h b/XEngine_Source/MQCore_MemoryCache/MemoryCache_Define.h index 98d6b74..7f27fd2 100644 --- a/XEngine_Source/MQCore_MemoryCache/MemoryCache_Define.h +++ b/XEngine_Source/MQCore_MemoryCache/MemoryCache_Define.h @@ -13,12 +13,13 @@ typedef enum { ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_QUERY = 0, - ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_INSERT = 1 + ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_INSERT = 1, + ENUM_MEMORYCACHE_CALLBACK_TYPE_USER_QUERY = 10 }ENUM_MEMORYCACHE_CALLBACK_TYPE; ////////////////////////////////////////////////////////////////////////// // 导出的回调 ////////////////////////////////////////////////////////////////////////// -typedef void(CALLBACK* CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE)(ENUM_MEMORYCACHE_CALLBACK_TYPE enMemoryType, bool bSuccess, size_t nListCount, XENGINE_DBMESSAGEQUEUE* pSt_DBInfo, XPVOID lParam); +typedef void(CALLBACK* CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE)(ENUM_MEMORYCACHE_CALLBACK_TYPE enMemoryType, bool bSuccess, size_t nListCount, XPVOID pSt_DBInfo, XPVOID lParam); ////////////////////////////////////////////////////////////////////////// // 导出的函数 ////////////////////////////////////////////////////////////////////////// @@ -34,17 +35,17 @@ extern "C" XLONG MemoryCache_GetLastError(int *pInt_SysError = NULL); 类型:整数型 可空:N 意思:允许的最后更新时间存在秒数 - 参数.二:nTimeStart + 参数.二:nTimeCount In/Out:In 类型:整数型 可空:N - 意思:允许的最大保留时间 + 意思:允许的最大保留时间.将不关心是否使用,0不启用 返回值 类型:逻辑型 意思:是否成功 备注: *********************************************************************/ -extern "C" bool MemoryCache_DBData_Init(int nTimeLast, int nTimeStart, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam = NULL); +extern "C" bool MemoryCache_DBData_Init(int nTimeLast, int nTimeCount, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam = NULL); /******************************************************************** 函数名称:MemoryCache_DBData_SetHandle 函数功能:设置句柄 @@ -128,4 +129,91 @@ extern "C" bool MemoryCache_DBData_DataDelete(XENGINE_DBMESSAGEQUEUE* pSt_DBMess 意思:是否成功 备注: *********************************************************************/ -extern "C" bool MemoryCache_DBData_QueueInsert(LPCXSTR lpszSQLStr, XENGINE_DBMESSAGEQUEUE* pSt_DBMessageInfo); \ No newline at end of file +extern "C" bool MemoryCache_DBData_QueueInsert(LPCXSTR lpszSQLStr, XENGINE_DBMESSAGEQUEUE* pSt_DBMessageInfo); +/************************************************************************* + 用户信息高速缓存导出函数 +**************************************************************************/ +/******************************************************************** +函数名称:MemoryCache_DBUser_Init +函数功能:初始化高速缓存管理器 + 参数.一:nTimeLast + In/Out:In + 类型:整数型 + 可空:N + 意思:允许的最后更新时间存在秒数 + 参数.二:nTimeCount + In/Out:In + 类型:整数型 + 可空:N + 意思:允许的最大保留时间.将不关心是否使用,0不启用 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool MemoryCache_DBUser_Init(int nTimeLast, int nTimeCount, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam = NULL); +/******************************************************************** +函数名称:MemoryCache_DBUser_SetHandle +函数功能:设置句柄 + 参数.一:xhDBSQL + In/Out:In + 类型:句柄 + 可空:N + 意思:数据库句柄 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool MemoryCache_DBUser_SetHandle(XNETHANDLE xhDBSQL); +/******************************************************************** +函数名称:MemoryCache_DBUser_Destory +函数功能:销毁高速缓存管理器 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool MemoryCache_DBUser_Destory(); +/******************************************************************** +函数名称:MemoryCache_DBUser_DataInsert +函数功能:插入一条数据到高速缓存 + 参数.一:pSt_DBUserInfo + In/Out:In + 类型:数据结构指针 + 可空:N + 意思:输入要插入的信息 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool MemoryCache_DBUser_DataInsert(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo); +/******************************************************************** +函数名称:MemoryCache_DBUser_DataQuery +函数功能:查询高速缓存 + 参数.一:pSt_DBUserInfo + In/Out:In + 类型:数据结构指针 + 可空:N + 意思:输入要查询的信息 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool MemoryCache_DBUser_DataQuery(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo); +/******************************************************************** +函数名称:MemoryCache_DBUser_DataDelete +函数功能:删除高速缓存 + 参数.一:pSt_DBUserInfo + In/Out:In + 类型:数据结构指针 + 可空:N + 意思:输入要操作的信息 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool MemoryCache_DBUser_DataDelete(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo); \ No newline at end of file diff --git a/XEngine_Source/MQCore_MemoryCache/pch.cpp b/XEngine_Source/MQCore_MemoryCache/pch.cpp index fe28202..1a33eb5 100644 --- a/XEngine_Source/MQCore_MemoryCache/pch.cpp +++ b/XEngine_Source/MQCore_MemoryCache/pch.cpp @@ -1,5 +1,6 @@ #include "pch.h" #include "MemoryCache_DBData/MemoryCache_DBData.h" +#include "MemoryCache_DBUser/MemoryCache_DBUser.h" /******************************************************************** // Created: 2024/11/21 15:01:53 // File Name: D:\XEngine_MQService\XEngine_Source\MQCore_MemoryCache\pch.cpp @@ -15,6 +16,7 @@ bool MemoryCache_IsErrorOccur = false; XLONG MemoryCache_dwErrorCode = 0; ////////////////////////////////////////////////////////////////////////// CMemoryCache_DBData m_MemoryDBData; +CMemoryCache_DBUser m_MemoryDBUser; ////////////////////////////////////////////////////////////////////////// // 导出的函数 ////////////////////////////////////////////////////////////////////////// @@ -29,9 +31,9 @@ extern "C" XLONG MemoryCache_GetLastError(int* pInt_SysError) /************************************************************************* 高速缓存导出函数 **************************************************************************/ -extern "C" bool MemoryCache_DBData_Init(int nTimeLast, int nTimeStart, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam) +extern "C" bool MemoryCache_DBData_Init(int nTimeLast, int nTimeCount, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam) { - return m_MemoryDBData.MemoryCache_DBData_Init(nTimeLast, nTimeStart, fpCall_MemoryCache, lParam); + return m_MemoryDBData.MemoryCache_DBData_Init(nTimeLast, nTimeCount, fpCall_MemoryCache, lParam); } extern "C" bool MemoryCache_DBData_SetHandle(XNETHANDLE xhDBSQL) { @@ -56,4 +58,31 @@ extern "C" bool MemoryCache_DBData_DataDelete(XENGINE_DBMESSAGEQUEUE* pSt_DBMess extern "C" bool MemoryCache_DBData_QueueInsert(LPCXSTR lpszSQLStr, XENGINE_DBMESSAGEQUEUE* pSt_DBMessageInfo) { return m_MemoryDBData.MemoryCache_DBData_QueueInsert(lpszSQLStr, pSt_DBMessageInfo); +} +/************************************************************************* + 用户信息高速缓存导出函数 +**************************************************************************/ +extern "C" bool MemoryCache_DBUser_Init(int nTimeLast, int nTimeCount, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_CACHE fpCall_MemoryCache, XPVOID lParam) +{ + return m_MemoryDBUser.MemoryCache_DBUser_Init(nTimeLast, nTimeCount, fpCall_MemoryCache, lParam); +} +extern "C" bool MemoryCache_DBUser_SetHandle(XNETHANDLE xhDBSQL) +{ + return m_MemoryDBUser.MemoryCache_DBUser_SetHandle(xhDBSQL); +} +extern "C" bool MemoryCache_DBUser_Destory() +{ + return m_MemoryDBUser.MemoryCache_DBUser_Destory(); +} +extern "C" bool MemoryCache_DBUser_DataInsert(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo) +{ + return m_MemoryDBUser.MemoryCache_DBUser_DataInsert(pSt_DBUserInfo); +} +extern "C" bool MemoryCache_DBUser_DataQuery(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo) +{ + return m_MemoryDBUser.MemoryCache_DBUser_DataQuery(pSt_DBUserInfo); +} +extern "C" bool MemoryCache_DBUser_DataDelete(XENGINE_PROTOCOL_USERINFO* pSt_DBUserInfo) +{ + return m_MemoryDBUser.MemoryCache_DBUser_DataDelete(pSt_DBUserInfo); } \ No newline at end of file diff --git a/XEngine_Source/MQCore_ProtocolModule/MQCore_ProtocolModule.vcxproj b/XEngine_Source/MQCore_ProtocolModule/MQCore_ProtocolModule.vcxproj index 77a2213..1729975 100644 --- a/XEngine_Source/MQCore_ProtocolModule/MQCore_ProtocolModule.vcxproj +++ b/XEngine_Source/MQCore_ProtocolModule/MQCore_ProtocolModule.vcxproj @@ -30,27 +30,27 @@ DynamicLibrary true v143 - MultiByte + Unicode DynamicLibrary false v143 true - MultiByte + Unicode DynamicLibrary true v143 - MultiByte + Unicode DynamicLibrary false v143 true - MultiByte + Unicode @@ -99,6 +99,8 @@ Use pch.h 4819 + stdcpp20 + stdc17 Windows @@ -119,6 +121,9 @@ pch.h MultiThreaded 4819 + stdcpp20 + stdc17 + /utf-8 %(AdditionalOptions) Windows @@ -137,6 +142,8 @@ true Use pch.h + stdcpp20 + stdc17 Windows @@ -157,6 +164,9 @@ pch.h MultiThreaded 4819 + stdcpp20 + stdc17 + /utf-8 %(AdditionalOptions) Windows diff --git a/XEngine_Source/MQCore_ProtocolModule/Makefile b/XEngine_Source/MQCore_ProtocolModule/Makefile index 07e7252..da415a8 100644 --- a/XEngine_Source/MQCore_ProtocolModule/Makefile +++ b/XEngine_Source/MQCore_ProtocolModule/Makefile @@ -1,4 +1,4 @@ -CC = g++ -Wall -std=c++17 -fPIC +CC = g++ -Wall -std=c++20 -fPIC PLATFORM = linux PLATVER = PLATDIR = @@ -7,7 +7,7 @@ LIBFLAG = RELEASE = 0 LOADHDR = -I ./ -I ../XEngine_Depend/XEngine_Module/jsoncpp LOADSO = -L ../XEngine_Depend/XEngine_Module/jsoncpp -LIB = -ljsoncpp -lXEngine_BaseLib -lXEngine_OPenSsl -lRfcComponents_MQTTProtocol +LIB = -ljsoncpp -lXEngine_BaseLib -lXEngine_Cryption -lRfcComponents_MQTTProtocol LIBEX = OBJECTS = ProtocolModule_Packet.o ProtocolModule_Parse.o pch.o diff --git a/XEngine_Source/MQCore_ProtocolModule/ProtocolModule_Packet/ProtocolModule_Packet.cpp b/XEngine_Source/MQCore_ProtocolModule/ProtocolModule_Packet/ProtocolModule_Packet.cpp index 62f2d50..fed50f4 100644 --- a/XEngine_Source/MQCore_ProtocolModule/ProtocolModule_Packet/ProtocolModule_Packet.cpp +++ b/XEngine_Source/MQCore_ProtocolModule/ProtocolModule_Packet/ProtocolModule_Packet.cpp @@ -829,7 +829,7 @@ bool CProtocolModule_Packet::ProtocolModule_Packet_WSCommon(XENGINE_PROTOCOLHDR* } memset(ptszBaseBuffer, '\0', XENGINE_MEMORY_SIZE_MAX); - OPenSsl_Codec_Base64(lpszMsgBuffer, ptszBaseBuffer, &nBLen, true); + Cryption_Codec_Base64(lpszMsgBuffer, ptszBaseBuffer, &nBLen, true); st_JsonPayload["nPayLen"] = nBLen; st_JsonPayload["tszPayData"] = ptszBaseBuffer; } @@ -861,7 +861,7 @@ bool CProtocolModule_Packet::ProtocolModule_Packet_MQTTCommon(XENGINE_PROTOCOLHD XCHAR tszRVBuffer[1024]; MQTTPROTOCOL_HDRPROPERTY** ppSt_HDRProperty; - BaseLib_OperatorMemory_Malloc((XPPPMEM)&ppSt_HDRProperty, nListCount, sizeof(MQTTPROTOCOL_HDRPROPERTY)); + BaseLib_Memory_Malloc((XPPPMEM)&ppSt_HDRProperty, nListCount, sizeof(MQTTPROTOCOL_HDRPROPERTY)); ppSt_HDRProperty[0]->nProLen = 4; ppSt_HDRProperty[0]->st_unValue.nValue = 1024000; @@ -889,7 +889,7 @@ bool CProtocolModule_Packet::ProtocolModule_Packet_MQTTCommon(XENGINE_PROTOCOLHD MQTTProtocol_Packet_REPConnect(tszRVBuffer, &nRVLen, 0, XENGINE_RFCCOMPONENTS_MQTT_PROTOCOL_REASON_SUCCESS, &ppSt_HDRProperty, nListCount); MQTTProtocol_Packet_Header(ptszMsgBuffer, pInt_MsgLen, XENGINE_RFCCOMPONENTS_MQTT_PROTOCOL_TYPE_CONNACK, tszRVBuffer, nRVLen); - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_HDRProperty, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSt_HDRProperty, nListCount); } else { diff --git a/XEngine_Source/MQCore_ProtocolModule/ProtocolModule_Parse/ProtocolModule_Parse.cpp b/XEngine_Source/MQCore_ProtocolModule/ProtocolModule_Parse/ProtocolModule_Parse.cpp index ee32c9f..7f12c5b 100644 --- a/XEngine_Source/MQCore_ProtocolModule/ProtocolModule_Parse/ProtocolModule_Parse.cpp +++ b/XEngine_Source/MQCore_ProtocolModule/ProtocolModule_Parse/ProtocolModule_Parse.cpp @@ -209,7 +209,7 @@ bool CProtocolModule_Parse::ProtocolModule_Parse_Websocket(LPCXSTR lpszMsgBuffer if (ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_BIN == pSt_ProtocolHdr->byVersion) { int nBLen = st_JsonPayLoad["nPayLen"].asInt(); - OPenSsl_Codec_Base64(st_JsonPayLoad["tszPayData"].asCString(), ptszMsgBuffer + nPos, &nBLen, false); + Cryption_Codec_Base64(st_JsonPayLoad["tszPayData"].asCString(), ptszMsgBuffer + nPos, &nBLen, false); *pInt_MsgLen += nBLen; } else diff --git a/XEngine_Source/MQCore_ProtocolModule/pch.h b/XEngine_Source/MQCore_ProtocolModule/pch.h index 7aa9d39..65e187b 100644 --- a/XEngine_Source/MQCore_ProtocolModule/pch.h +++ b/XEngine_Source/MQCore_ProtocolModule/pch.h @@ -21,8 +21,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -48,7 +48,7 @@ extern XLONG Protocol_dwErrorCode; #ifdef _MSC_BUILD #pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib") -#pragma comment(lib,"XEngine_Core/XEngine_OPenSsl") +#pragma comment(lib,"XEngine_Core/XEngine_Cryption") #pragma comment(lib,"XEngine_RfcComponents/RfcComponents_MQTTProtocol.lib") #ifdef _DEBUG #ifdef _WIN64 diff --git a/XEngine_Source/MQCore_SessionModule/MQCore_SessionModule.vcxproj b/XEngine_Source/MQCore_SessionModule/MQCore_SessionModule.vcxproj index 31c065f..6cd75df 100644 --- a/XEngine_Source/MQCore_SessionModule/MQCore_SessionModule.vcxproj +++ b/XEngine_Source/MQCore_SessionModule/MQCore_SessionModule.vcxproj @@ -30,27 +30,27 @@ DynamicLibrary true v143 - MultiByte + Unicode DynamicLibrary false v143 true - MultiByte + Unicode DynamicLibrary true v143 - MultiByte + Unicode DynamicLibrary false v143 true - MultiByte + Unicode @@ -99,6 +99,8 @@ Use pch.h 4819 + stdcpp20 + stdc17 Windows @@ -119,6 +121,9 @@ pch.h MultiThreaded 4819 + stdcpp20 + stdc17 + /utf-8 %(AdditionalOptions) Windows @@ -137,6 +142,8 @@ true Use pch.h + stdcpp20 + stdc17 Windows @@ -157,6 +164,9 @@ pch.h MultiThreaded 4819 + stdcpp20 + stdc17 + /utf-8 %(AdditionalOptions) Windows diff --git a/XEngine_Source/MQCore_SessionModule/Makefile b/XEngine_Source/MQCore_SessionModule/Makefile index 8661497..afdd9b7 100644 --- a/XEngine_Source/MQCore_SessionModule/Makefile +++ b/XEngine_Source/MQCore_SessionModule/Makefile @@ -1,4 +1,4 @@ -CC = g++ -Wall -std=c++17 -fPIC +CC = g++ -Wall -std=c++20 -fPIC PLATFORM = linux PLATVER = PLATDIR = diff --git a/XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.cpp b/XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.cpp index be18bcc..493de2c 100644 --- a/XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.cpp +++ b/XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.cpp @@ -115,7 +115,7 @@ bool CSessionModule_Client::SessionModule_Client_Delete(LPCXSTR lpszClientAddr) Session_IsErrorOccur = false; st_Locker.lock(); - unordered_map::iterator stl_MapIterator = stl_MapSession.find(lpszClientAddr); + unordered_map::iterator stl_MapIterator = stl_MapSession.find(lpszClientAddr); if (stl_MapIterator != stl_MapSession.end()) { stl_MapSession.erase(stl_MapIterator); @@ -183,7 +183,7 @@ bool CSessionModule_Client::SessionModule_Client_GetUser(LPCXSTR lpszSessionStr, return false; } st_Locker.lock_shared(); - unordered_map::iterator stl_MapIterator = stl_MapSession.find(lpszSessionStr); + unordered_map::iterator stl_MapIterator = stl_MapSession.find(lpszSessionStr); if (stl_MapIterator == stl_MapSession.end()) { Session_IsErrorOccur = true; @@ -328,7 +328,7 @@ bool CSessionModule_Client::SessionModule_Client_GetType(LPCXSTR lpszSessionStr, return false; } st_Locker.lock_shared(); - unordered_map::iterator stl_MapIterator = stl_MapSession.find(lpszSessionStr); + unordered_map::iterator stl_MapIterator = stl_MapSession.find(lpszSessionStr); if (stl_MapIterator == stl_MapSession.end()) { Session_IsErrorOccur = true; @@ -373,7 +373,7 @@ bool CSessionModule_Client::SessionModule_Client_GetExist(LPCXSTR lpszClientAddr if (NULL == lpszClientAddr) { bool bFound = false; - unordered_map::iterator stl_MapIterator = stl_MapSession.begin(); + unordered_map::iterator stl_MapIterator = stl_MapSession.begin(); for (int i = 0; stl_MapIterator != stl_MapSession.end(); stl_MapIterator++, i++) { if (0 == _tcsxnicmp(lpszClientUser, stl_MapIterator->second.st_UserInfo.tszUserName, _tcsxlen(stl_MapIterator->second.st_UserInfo.tszUserName))) @@ -392,7 +392,7 @@ bool CSessionModule_Client::SessionModule_Client_GetExist(LPCXSTR lpszClientAddr } else { - unordered_map::iterator stl_MapIterator = stl_MapSession.find(lpszClientAddr); + unordered_map::iterator stl_MapIterator = stl_MapSession.find(lpszClientAddr); if (stl_MapIterator == stl_MapSession.end()) { Session_IsErrorOccur = true; @@ -432,10 +432,10 @@ bool CSessionModule_Client::SessionModule_Client_GetListAddr(XCHAR*** ppptszClie Session_IsErrorOccur = false; *pInt_ListCount = stl_MapSession.size(); - BaseLib_OperatorMemory_Malloc((XPPPMEM)ppptszClientList, stl_MapSession.size(), 128); + BaseLib_Memory_Malloc((XPPPMEM)ppptszClientList, stl_MapSession.size(), 128); st_Locker.lock_shared(); - unordered_map::iterator stl_MapIterator = stl_MapSession.begin(); + unordered_map::iterator stl_MapIterator = stl_MapSession.begin(); for (int i = 0; stl_MapIterator != stl_MapSession.end(); stl_MapIterator++, i++) { if (bAddr) diff --git a/XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.h b/XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.h index 6eef537..11a8e5a 100644 --- a/XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.h +++ b/XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.h @@ -38,5 +38,5 @@ class CSessionModule_Client private: shared_mutex st_Locker; private: - unordered_map stl_MapSession; + unordered_map stl_MapSession; }; diff --git a/XEngine_Source/MQCore_SessionModule/pch.h b/XEngine_Source/MQCore_SessionModule/pch.h index d4db086..4ee3705 100644 --- a/XEngine_Source/MQCore_SessionModule/pch.h +++ b/XEngine_Source/MQCore_SessionModule/pch.h @@ -29,11 +29,6 @@ #include "Session_Define.h" #include "Session_Error.h" using namespace std; -#ifdef _UNICODE -typedef std::wstring tstring; -#else -typedef std::string tstring; -#endif /******************************************************************** // Created: 2021/07/02 10:16:47 // File Name: D:\XEngine_MQService\XEngine_Source\MQCore_SessionModule\pch.h diff --git a/XEngine_Source/VSCopy_Debug.bat b/XEngine_Source/VSCopy_Debug.bat index 4d469df..396027d 100644 --- a/XEngine_Source/VSCopy_Debug.bat +++ b/XEngine_Source/VSCopy_Debug.bat @@ -3,11 +3,13 @@ copy /y "D:\XEngine\XEngine_SourceCode\Debug\XEngine_BaseSafe.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\XEngine_Algorithm.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\XEngine_Core.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\XEngine_ManagePool.dll" "./" -copy /y "D:\XEngine\XEngine_SourceCode\Debug\XEngine_OPenSsl.dll" "./" +copy /y "D:\XEngine\XEngine_SourceCode\Debug\XEngine_Cryption.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\XEngine_SystemApi.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\XClient_APIHelp.dll" "./" +copy /y "D:\XEngine\XEngine_SourceCode\Debug\NetHelp_APIHelp.dll" "./" + copy /y "D:\XEngine\XEngine_SourceCode\Debug\HelpComponents_Packets.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\HelpComponents_XLog.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\HelpComponents_DataBase.dll" "./" diff --git a/XEngine_Source/VSCopy_x64.bat b/XEngine_Source/VSCopy_x64.bat index 7967112..52af2f8 100644 --- a/XEngine_Source/VSCopy_x64.bat +++ b/XEngine_Source/VSCopy_x64.bat @@ -3,11 +3,13 @@ copy /y "%XEngine_Lib64%\XEngine_BaseLib\XEngine_BaseSafe.dll" "./" copy /y "%XEngine_Lib64%\XEngine_BaseLib\XEngine_Algorithm.dll" "./" copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_Core.dll" "./" copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_ManagePool.dll" "./" -copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_OPenSsl.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_Cryption.dll" "./" copy /y "%XEngine_Lib64%\XEngine_SystemSdk\XEngine_SystemApi.dll" "./" copy /y "%XEngine_Lib64%\XEngine_Client\XClient_APIHelp.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_NetHelp\NetHelp_APIHelp.dll" "./" + copy /y "%XEngine_Lib64%\XEngine_HelpComponents\HelpComponents_Packets.dll" "./" copy /y "%XEngine_Lib64%\XEngine_HelpComponents\HelpComponents_XLog.dll" "./" copy /y "%XEngine_Lib64%\XEngine_HelpComponents\HelpComponents_DataBase.dll" "./" diff --git a/XEngine_Source/VSCopy_x86.bat b/XEngine_Source/VSCopy_x86.bat index 37a5668..da0981d 100644 --- a/XEngine_Source/VSCopy_x86.bat +++ b/XEngine_Source/VSCopy_x86.bat @@ -3,11 +3,13 @@ copy /y "%XEngine_Lib32%\XEngine_BaseLib\XEngine_BaseSafe.dll" "./" copy /y "%XEngine_Lib32%\XEngine_BaseLib\XEngine_Algorithm.dll" "./" copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_Core.dll" "./" copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_ManagePool.dll" "./" -copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_OPenSsl.dll" "./" +copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_Cryption.dll" "./" copy /y "%XEngine_Lib32%\XEngine_SystemSdk\XEngine_SystemApi.dll" "./" copy /y "%XEngine_Lib32%\XEngine_Client\XClient_APIHelp.dll" "./" +copy /y "%XEngine_Lib32%\XEngine_NetHelp\NetHelp_APIHelp.dll" "./" + copy /y "%XEngine_Lib32%\XEngine_HelpComponents\HelpComponents_Packets.dll" "./" copy /y "%XEngine_Lib32%\XEngine_HelpComponents\HelpComponents_XLog.dll" "./" copy /y "%XEngine_Lib32%\XEngine_HelpComponents\HelpComponents_DataBase.dll" "./" diff --git a/XEngine_Source/XEngine_Depend b/XEngine_Source/XEngine_Depend index 1c1452f..bcf8d94 160000 --- a/XEngine_Source/XEngine_Depend +++ b/XEngine_Source/XEngine_Depend @@ -1 +1 @@ -Subproject commit 1c1452f13720d22834e09c7e4e78042698411486 +Subproject commit bcf8d946890a2f2fb39eec16e64a634a8ece52c7 diff --git a/XEngine_Source/XEngine_MQServiceApp/MQService_Hdr.h b/XEngine_Source/XEngine_MQServiceApp/MQService_Hdr.h index e9113e9..fd4c49c 100644 --- a/XEngine_Source/XEngine_MQServiceApp/MQService_Hdr.h +++ b/XEngine_Source/XEngine_MQServiceApp/MQService_Hdr.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -45,11 +46,6 @@ using namespace std; #include "../XEngine_Depend/XEngine_Module/XEngine_InfoReport/InfoReport_Define.h" #include "../XEngine_Depend/XEngine_Module/XEngine_InfoReport/InfoReport_Error.h" -#ifdef _UNICODE -typedef std::wstring tstring; -#else -typedef std::string tstring; -#endif #include "../XQueue_ProtocolHdr.h" #include "../MQCore_ConfigModule/Config_Define.h" #include "../MQCore_ConfigModule/Config_Error.h" diff --git a/XEngine_Source/XEngine_MQServiceApp/MQService_HttpTask.cpp b/XEngine_Source/XEngine_MQServiceApp/MQService_HttpTask.cpp index 98e3eca..4ce4914 100644 --- a/XEngine_Source/XEngine_MQServiceApp/MQService_HttpTask.cpp +++ b/XEngine_Source/XEngine_MQServiceApp/MQService_HttpTask.cpp @@ -29,12 +29,12 @@ XHTHREAD CALLBACK MessageQueue_HttpThread(XPVOID lParam) if (HttpProtocol_Server_GetMemoryEx(xhHTTPPacket, ppSst_ListAddr[i]->tszClientAddr, &ptszMsgBuffer, &nMsgLen, &st_HTTPReqparam, &ppszHdrList, &nHdrCount)) { MessageQueue_Http_Handle(&st_HTTPReqparam, ppSst_ListAddr[i]->tszClientAddr, ptszMsgBuffer, nMsgLen, ppszHdrList, nHdrCount); - BaseLib_OperatorMemory_FreeCStyle((VOID**)&ptszMsgBuffer); - BaseLib_OperatorMemory_Free((XPPPMEM)&ppszHdrList, nHdrCount); + BaseLib_Memory_FreeCStyle((VOID**)&ptszMsgBuffer); + BaseLib_Memory_Free((XPPPMEM)&ppszHdrList, nHdrCount); } } } - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSst_ListAddr, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSst_ListAddr, nListCount); } return 0; } @@ -71,11 +71,11 @@ bool MessageQueue_Http_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXST return false; } //获取函数 - BaseLib_OperatorString_GetKeyValue(ppSt_ListUrl[0], _X("="), tszKey, tszValue); + BaseLib_String_GetKeyValue(ppSt_ListUrl[0], _X("="), tszKey, tszValue); if (0 == _tcsxnicmp(lpszAPIGet, tszValue, _tcsxlen(lpszAPIGet))) { memset(tszValue, '\0', MAX_PATH); - BaseLib_OperatorString_GetKeyValue(ppSt_ListUrl[1], _X("="), tszKey, tszValue); + BaseLib_String_GetKeyValue(ppSt_ListUrl[1], _X("="), tszKey, tszValue); if (0 == _tcsxnicmp(lpszAPIUser, tszValue, _tcsxlen(lpszAPIUser))) { //用户 http://127.0.0.1:5202/api?function=get&method=user @@ -83,7 +83,7 @@ bool MessageQueue_Http_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXST XENGINE_PROTOCOL_USERINFO** ppSt_UserInfo; DBModule_MQUser_UserList(&ppSt_UserInfo, &nListCount); ProtocolModule_Packet_UserList(tszPKTBuffer, &nPKTLen, &ppSt_UserInfo, nListCount); - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_UserInfo, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSt_UserInfo, nListCount); XEngine_MQXService_Send(lpszClientAddr, tszPKTBuffer, nPKTLen, XENGINE_MQAPP_NETTYPE_HTTP); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,发送的获取用户列表请求成功,获取到的用户列表个数:%d"), lpszClientAddr, nListCount); @@ -100,10 +100,10 @@ bool MessageQueue_Http_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXST int nListCount = 0; XCHAR** pptszListAddr; - BaseLib_OperatorString_GetKeyValue(ppSt_ListUrl[2], _X("="), tszKey, tszValue); + BaseLib_String_GetKeyValue(ppSt_ListUrl[2], _X("="), tszKey, tszValue); SessionModule_Client_GetListAddr(&pptszListAddr, &nListCount, _ttxoi(tszValue)); ProtocolModule_Packet_OnlineList(tszPKTBuffer, &nPKTLen, &pptszListAddr, nListCount); - BaseLib_OperatorMemory_Free((XPPPMEM)&pptszListAddr, nListCount); + BaseLib_Memory_Free((XPPPMEM)&pptszListAddr, nListCount); XEngine_MQXService_Send(lpszClientAddr, tszPKTBuffer, nPKTLen, XENGINE_MQAPP_NETTYPE_HTTP); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,发送的获取在线用户列表请求成功,获取到的列表个数:%d"), lpszClientAddr, nListCount); } @@ -116,14 +116,14 @@ bool MessageQueue_Http_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXST XCHAR** ppszTableName; DBModule_MQData_ShowTable(&ppszTableName, &nListCount); ProtocolModule_Packet_TopicList(tszPKTBuffer, &nPKTLen, &ppszTableName, nListCount); - BaseLib_OperatorMemory_Free((XPPPMEM)&ppszTableName, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppszTableName, nListCount); XEngine_MQXService_Send(lpszClientAddr, tszPKTBuffer, nPKTLen, XENGINE_MQAPP_NETTYPE_HTTP); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,发送的获取主题列表请求成功,获取到的主题列表个数:%d"), lpszClientAddr, nListCount); } else { int nDBCount = 0; - BaseLib_OperatorString_GetKeyValue(ppSt_ListUrl[2], _X("="), tszKey, tszValue); + BaseLib_String_GetKeyValue(ppSt_ListUrl[2], _X("="), tszKey, tszValue); DBModule_MQData_GetLeftCount(tszValue, 0, &nDBCount); ProtocolModule_Packet_TopicName(tszPKTBuffer, &nPKTLen, tszValue, nDBCount); XEngine_MQXService_Send(lpszClientAddr, tszPKTBuffer, nPKTLen, XENGINE_MQAPP_NETTYPE_HTTP); diff --git a/XEngine_Source/XEngine_MQServiceApp/MQService_MQTTTask.cpp b/XEngine_Source/XEngine_MQServiceApp/MQService_MQTTTask.cpp index a0fd4b1..0e84c1c 100644 --- a/XEngine_Source/XEngine_MQServiceApp/MQService_MQTTTask.cpp +++ b/XEngine_Source/XEngine_MQServiceApp/MQService_MQTTTask.cpp @@ -25,17 +25,17 @@ XHTHREAD CALLBACK MessageQueue_MQTTThread(XPVOID lParam) if (MQTTProtocol_Parse_Recv(ppSst_ListAddr[i]->tszClientAddr, &st_MQTTHdr, &ptszMSGBuffer, &nMSGLen)) { MQService_MQTT_Handle(ppSst_ListAddr[i]->tszClientAddr, &st_MQTTHdr, ptszMSGBuffer, nMSGLen); - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMSGBuffer); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMSGBuffer); } } } - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSst_ListAddr, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSst_ListAddr, nListCount); } return 0; } void Packet_Property(MQTTPROTOCOL_HDRPROPERTY*** pppSt_HDRProperty, int nListCount) { - BaseLib_OperatorMemory_Malloc((XPPPMEM)pppSt_HDRProperty, nListCount, sizeof(MQTTPROTOCOL_HDRPROPERTY)); + BaseLib_Memory_Malloc((XPPPMEM)pppSt_HDRProperty, nListCount, sizeof(MQTTPROTOCOL_HDRPROPERTY)); (*pppSt_HDRProperty)[0]->nProLen = 4; (*pppSt_HDRProperty)[0]->st_unValue.nValue = 1024000; @@ -87,7 +87,7 @@ bool MQService_MQTT_Handle(LPCXSTR lpszClientAddr, MQTTPROTOCOL_FIXEDHEADER* pSt XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("MQTT客户端:%s,请求链接失败,错误码:%lX"), lpszClientAddr, MQTTProtocol_GetLastError()); return false; } - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_HDRProperty, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSt_HDRProperty, nListCount); XENGINE_PROTOCOLHDR st_ProtocolHdr = {}; XENGINE_PROTOCOL_USERAUTH st_ProtocolAuth = {}; diff --git a/XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp b/XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp index 34ce1d5..31a35b6 100644 --- a/XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp +++ b/XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp @@ -26,11 +26,11 @@ XHTHREAD CALLBACK MessageQueue_TCPThread(XPVOID lParam) if (HelpComponents_Datas_GetMemoryEx(xhTCPPacket, ppSst_ListAddr[i]->tszClientAddr, &ptszMsgBuffer, &nMsgLen, &st_ProtocolHdr)) { MessageQueue_TCP_Handle(&st_ProtocolHdr, ppSst_ListAddr[i]->tszClientAddr, ptszMsgBuffer, nMsgLen, XENGINE_MQAPP_NETTYPE_TCP); - BaseLib_OperatorMemory_FreeCStyle((VOID**)&ptszMsgBuffer); + BaseLib_Memory_FreeCStyle((VOID**)&ptszMsgBuffer); } } } - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSst_ListAddr, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSst_ListAddr, nListCount); } return 0; } @@ -88,7 +88,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC if (SessionModule_Client_GetAddr(st_ProtocolAuth.tszUserName)) { - pSt_ProtocolHdr->wReserve = 700; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_LOGGED; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求登录到服务失败,因为用户已经登录了"), lpszClientType, lpszClientAddr); @@ -111,20 +111,20 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC APIClient_Http_Request(_X("POST"), st_ServiceCfg.st_XPass.tszPassLogin, tszSDBuffer, &nHTTPCode, &ptszSDBuffer, &nSDLen, NULL, NULL, &st_HTTPParament); if (200 != nHTTPCode) { - pSt_ProtocolHdr->wReserve = 701; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_HTTP; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求远程验证失败,HTTPCode:%d"), lpszClientType, lpszClientAddr, nHTTPCode); return false; } ProtocolModule_Parse_Websocket(ptszSDBuffer, nSDLen, NULL, (XCHAR*)&st_UserInfo, &nRVLen); - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszSDBuffer); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszSDBuffer); } else { if (!DBModule_MQUser_UserQuery(&st_UserInfo)) { - pSt_ProtocolHdr->wReserve = 701; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_USERPASS; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求本地验证失败,用户或者密码不正确,错误:%lX"), lpszClientType, lpszClientAddr, SessionModule_GetLastError()); @@ -146,7 +146,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC if (!SessionModule_Client_GetUser(lpszClientAddr, tszUserName)) { - pSt_ProtocolHdr->wReserve = 711; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_NOTLOGIN; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求登出失败,用户没有登录"), lpszClientType, lpszClientAddr); @@ -201,7 +201,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC APIClient_Http_Request(_X("POST"), st_ServiceCfg.st_XPass.tszPassRegister, tszSDBuffer, &nHTTPCode, NULL, NULL, NULL, NULL, &st_HTTPParament); if (200 != nHTTPCode) { - pSt_ProtocolHdr->wReserve = 701; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_APIREG; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求远程注册失败,HTTPCode:%d"), lpszClientType, lpszClientAddr, nHTTPCode); @@ -212,7 +212,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC { if (DBModule_MQUser_UserQuery(&st_UserInfo)) { - pSt_ProtocolHdr->wReserve = 721; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_EXISTED; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求用户注册失败,用户已经存在,错误:%lX"), lpszClientType, lpszClientAddr, SessionModule_GetLastError()); @@ -220,7 +220,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC } if (!DBModule_MQUser_UserInsert(&st_UserInfo)) { - pSt_ProtocolHdr->wReserve = 722; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_REGISTER; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求用户注册失败,插入数据库失败,错误:%lX"), lpszClientType, lpszClientAddr, SessionModule_GetLastError()); @@ -266,7 +266,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC APIClient_Http_Request(_X("POST"), st_ServiceCfg.st_XPass.tszPassUNReg, tszSDBuffer, &nHTTPCode, NULL, NULL, NULL, NULL, &st_HTTPParament); if (200 != nHTTPCode) { - pSt_ProtocolHdr->wReserve = 701; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_APIDEL; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求远程注销失败,错误:%lX,HTTPCode:%d"), lpszClientType, lpszClientAddr, nHTTPCode); @@ -277,7 +277,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC { if (!DBModule_MQUser_UserDelete(&st_UserInfo)) { - pSt_ProtocolHdr->wReserve = 721; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_DELETE; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求用户删除失败,删除数据库失败,错误:%lX"), lpszClientType, lpszClientAddr, SessionModule_GetLastError()); @@ -311,7 +311,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC if (!SessionModule_Client_GetUser(lpszClientAddr, tszUserName)) { - pSt_ProtocolHdr->wReserve = 700; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_NOTLOGIN; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求失败,用户没有通过验证"), lpszClientType, lpszClientAddr); @@ -347,13 +347,13 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC if (st_MQProtocol.nKeepTime > 0) { - XENGINE_LIBTIMER st_LibTime; - memset(&st_LibTime, '\0', sizeof(XENGINE_LIBTIMER)); + XENGINE_LIBTIME st_LibTime; + memset(&st_LibTime, '\0', sizeof(XENGINE_LIBTIME)); time_t nTimeStart = time(NULL); time_t nTimeEnd = nTimeStart + st_MQProtocol.nKeepTime; - BaseLib_OperatorTimeSpan_CalForTime(nTimeStart, nTimeEnd, &st_LibTime); - BaseLib_OperatorTime_TimeToStr(st_DBQueue.tszQueueLeftTime, NULL, true, &st_LibTime); + BaseLib_TimeSpan_CalForTime(nTimeStart, nTimeEnd, &st_LibTime); + BaseLib_Time_TimeToStr(st_DBQueue.tszQueueLeftTime, NULL, true, &st_LibTime); } //处理序列号 if (st_DBQueue.nQueueSerial > 0) @@ -367,7 +367,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC //找到了返回错误 if (pSt_ProtocolHdr->byIsReply) { - pSt_ProtocolHdr->wReserve = 701; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_EXISTED; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); } @@ -392,17 +392,17 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC if (st_MQProtocol.nPubTime > 0) { XENGINE_DBTIMERELEASE st_DBTime; - XENGINE_LIBTIMER st_LibTime; + XENGINE_LIBTIME st_LibTime; memset(&st_DBTime, '\0', sizeof(XENGINE_DBTIMERELEASE)); - memset(&st_LibTime, '\0', sizeof(XENGINE_LIBTIMER)); + memset(&st_LibTime, '\0', sizeof(XENGINE_LIBTIME)); st_DBTime.nIDMsg = st_DBQueue.nQueueSerial; st_DBTime.nIDTime = st_MQProtocol.nPubTime; _tcsxcpy(st_DBTime.tszQueueName, st_DBQueue.tszQueueName); - BaseLib_OperatorTime_TTimeToStuTime(st_MQProtocol.nPubTime, &st_LibTime); - BaseLib_OperatorTime_TimeToStr(st_DBQueue.tszQueuePublishTime, NULL, true, &st_LibTime); + BaseLib_Time_TTimeToStuTime(st_MQProtocol.nPubTime, &st_LibTime); + BaseLib_Time_TimeToStr(st_DBQueue.tszQueuePublishTime, NULL, true, &st_LibTime); DBModule_MQUser_TimeInsert(&st_DBTime); } else if (0 == st_MQProtocol.nPubTime) @@ -429,7 +429,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC SessionModule_Client_GetType(pptszListAddr[i], &nClientType); ProtocolModule_Packet_Common(nClientType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen, lpszMsgBuffer + sizeof(XENGINE_PROTOCOL_XMQ), nMsgLen - sizeof(XENGINE_PROTOCOL_XMQ)); XEngine_MQXService_Send(pptszListAddr[i], tszSDBuffer, nSDLen, nClientType); - BaseLib_OperatorMemory_Free((XPPPMEM)&pptszListAddr, nListCount); + BaseLib_Memory_Free((XPPPMEM)&pptszListAddr, nListCount); } } else @@ -477,7 +477,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC XEngine_MQXService_Send(tszUserAddr, tszSDBuffer, nSDLen, nClientType); } } - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListUser, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSt_ListUser, nListCount); } } _xstprintf(st_DBQueue.tszQueuePublishTime, _X("0")); @@ -492,7 +492,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC { if (pSt_ProtocolHdr->byIsReply) { - pSt_ProtocolHdr->wReserve = 702; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_INSERT; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); } @@ -524,7 +524,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC if (!DBModule_MQData_Query(&st_MessageQueue)) { - pSt_ProtocolHdr->wReserve = 722; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_MSGQUERY; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,主题:%s,获取消息数据失败,获取指定消息序列:%lld 失败,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial, DBModule_GetLastError()); @@ -538,7 +538,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC { if (1 != st_MSGAttr.byAttrActive) { - pSt_ProtocolHdr->wReserve = 723; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_BELONG; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,主题:%s,获取消息数据失败,获取指定消息序列:%lld 失败,错误:此消息不属于此用户"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial); @@ -551,12 +551,12 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC //有过期时间,判断是否过期 __int64x nTimeRet = 0; XCHAR tszTimeStr[MAX_PATH] = {}; - BaseLib_OperatorTime_TimeToStr(tszTimeStr); - BaseLib_OperatorTimeSpan_GetForStr(st_MessageQueue.tszQueueLeftTime, tszTimeStr, &nTimeRet, 3); + BaseLib_Time_TimeToStr(tszTimeStr); + BaseLib_TimeSpan_GetForStr(st_MessageQueue.tszQueueLeftTime, tszTimeStr, &nTimeRet, 3); //如果超时并且不允许主动获取,返回错误 if ((nTimeRet < 0) && (1 != st_MSGAttr.byAttrActive)) { - pSt_ProtocolHdr->wReserve = 724; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_TIMEOUT; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,主题:%s,获取消息数据失败,获取指定消息序列:%lld 失败,错误:消息超时"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial); @@ -568,7 +568,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC { if (1 != st_MSGAttr.byAttrActive) { - pSt_ProtocolHdr->wReserve = 725; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_PUBTIME; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,主题:%s,获取消息数据失败,获取指定消息序列:%lld 失败,错误:此为定时发布任务"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial); @@ -583,7 +583,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC _tcsxcpy(st_UserKey.tszUserName, tszUserName); if (!DBModule_MQUser_KeyQuery(&st_UserKey)) { - pSt_ProtocolHdr->wReserve = 723; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_KEYQUERY; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,主题:%s,获取消息数据失败,获取绑定信息失败,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, DBModule_GetLastError()); @@ -596,7 +596,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC _tcsxcpy(st_MessageQueue.tszQueueName, st_MQProtocol.tszMQKey); if (!DBModule_MQData_Query(&st_MessageQueue)) { - pSt_ProtocolHdr->wReserve = 724; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_MSGQUERY; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,主题:%s,序列:%lld,获取消息数据失败,无法继续,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial, DBModule_GetLastError()); @@ -615,8 +615,8 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC XCHAR tszTimeEnd[128]; memset(tszTimeEnd, '\0', sizeof(tszTimeEnd)); - BaseLib_OperatorTime_TimeToStr(tszTimeEnd); - BaseLib_OperatorTimeSpan_GetForStr(st_MessageQueue.tszQueueLeftTime, tszTimeEnd, &nTimeDiff, 3); + BaseLib_Time_TimeToStr(tszTimeEnd); + BaseLib_TimeSpan_GetForStr(st_MessageQueue.tszQueueLeftTime, tszTimeEnd, &nTimeDiff, 3); if (nTimeDiff > 0) { st_UserKey.nKeySerial++; @@ -654,6 +654,30 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("%s消息端:%s,主题:%s,序列:%lld,获取消息数据成功,消息大小:%d"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MessageQueue.nQueueSerial, st_MessageQueue.nMsgLen); } + else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQDELETE == pSt_ProtocolHdr->unOperatorCode) + { + XENGINE_DBMESSAGEQUEUE st_MessageQueue; + memset(&st_MessageQueue, '\0', sizeof(XENGINE_DBMESSAGEQUEUE)); + + pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPDELETE; + if (st_MQProtocol.nSerial <= 0) + { + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_SERIAL; + ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); + XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,主题:%s,获取消息数据失败,获取指定消息序列:%lld 失败,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial, DBModule_GetLastError()); + return false; + } + st_MessageQueue.nQueueSerial = st_MQProtocol.nSerial; + _tcsxcpy(st_MessageQueue.tszQueueName, st_MQProtocol.tszMQKey); + DBModule_MQData_Delete(&st_MessageQueue); + + pSt_ProtocolHdr->wReserve = 0; + pSt_ProtocolHdr->byVersion = st_MessageQueue.byMsgType; + ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); + XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("%s消息端:%s,主题:%s,序列:%lld,删除消息数据成功"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MessageQueue.nQueueSerial); + } else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICCREATE == pSt_ProtocolHdr->unOperatorCode) { pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICCREATE; @@ -662,7 +686,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC { if (pSt_ProtocolHdr->byIsReply) { - pSt_ProtocolHdr->wReserve = 751; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_CREATEKEY; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); } @@ -680,7 +704,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC { if (pSt_ProtocolHdr->byIsReply) { - pSt_ProtocolHdr->wReserve = 752; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_BINDOWNER; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); } @@ -717,7 +741,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC { if (pSt_ProtocolHdr->byIsReply) { - pSt_ProtocolHdr->wReserve = 761; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_DELOWNER; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); } @@ -753,7 +777,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC st_Userkey.nKeySerial = st_MQProtocol.nSerial; if (!DBModule_MQUser_KeyUPDate(&st_Userkey)) { - pSt_ProtocolHdr->wReserve = 710; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_KEYUP; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,设置消息队列主题更新失败,主题名称:%s,序列号:%lld,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial, DBModule_GetLastError()); @@ -766,7 +790,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC st_Userkey.nKeySerial = st_MQProtocol.nSerial; if (!DBModule_MQUser_KeyInsert(&st_Userkey)) { - pSt_ProtocolHdr->wReserve = 711; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_BINDKEY; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,设置消息队列主题创建失败,主题名称:%s,序列号:%lld,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial, DBModule_GetLastError()); @@ -790,7 +814,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC if (!DBModule_MQUser_KeyDelete(&st_Userkey)) { - pSt_ProtocolHdr->wReserve = 721; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_DELKEY; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,解除消息绑定订阅失败,可能没有找到主题用户,主题名称:%s,用户名称:%s,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, tszUserName, DBModule_GetLastError()); @@ -811,7 +835,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC memset(&st_MQNumber, '\0', sizeof(XENGINE_MQNUMBER)); if (!DBModule_MQData_GetSerial(st_MQProtocol.tszMQKey, &st_MQNumber.nCount, &st_DBStart, &st_DBEnd)) { - pSt_ProtocolHdr->wReserve = 741; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_SERIAL; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,获取消息队列序列属性失败,主题名称:%s,序列号:%lld,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nKeepTime == 1 ? "顺序" : "倒序", st_MQProtocol.nSerial, DBModule_GetLastError()); @@ -845,7 +869,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC { if (pSt_ProtocolHdr->byIsReply) { - pSt_ProtocolHdr->wReserve = 781; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_QUERYOWNER; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); } @@ -855,7 +879,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC //修改主题 if (!DBModule_MQData_ModifyTable(st_MQProtocol.tszMQKey, st_MQTopic.tszMQKey)) { - pSt_ProtocolHdr->wReserve = 782; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_MODIFYTOPIC; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,修改主题名称失败,原名称:%s,目标名:%s,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQTopic.tszMQKey, DBModule_GetLastError()); @@ -870,7 +894,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("%s消息端:%s,修改主题名称成功,原名称:%s,目标名:%s"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQTopic.tszMQKey); } - else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQMSGMODIFY == pSt_ProtocolHdr->unOperatorCode) + else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQMODIFY == pSt_ProtocolHdr->unOperatorCode) { XENGINE_DBMESSAGEQUEUE st_DBQueue; memset(&st_DBQueue, '\0', sizeof(XENGINE_DBMESSAGEQUEUE)); @@ -885,40 +909,40 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC if (st_MQProtocol.nKeepTime > 0) { - XENGINE_LIBTIMER st_LibTime; - memset(&st_LibTime, '\0', sizeof(XENGINE_LIBTIMER)); + XENGINE_LIBTIME st_LibTime; + memset(&st_LibTime, '\0', sizeof(XENGINE_LIBTIME)); time_t nTimeStart = time(NULL); time_t nTimeEnd = nTimeStart + st_MQProtocol.nKeepTime; - BaseLib_OperatorTimeSpan_CalForTime(nTimeStart, nTimeEnd, &st_LibTime); + BaseLib_TimeSpan_CalForTime(nTimeStart, nTimeEnd, &st_LibTime); _xstprintf(st_DBQueue.tszQueueLeftTime, _X("%04d-%02d-%02d %02d:%02d:%02d"), st_LibTime.wYear, st_LibTime.wMonth, st_LibTime.wDay, st_LibTime.wHour, st_LibTime.wMinute, st_LibTime.wSecond); } if (st_MQProtocol.nPubTime > 0) { XENGINE_DBTIMERELEASE st_DBTime; - XENGINE_LIBTIMER st_LibTime; + XENGINE_LIBTIME st_LibTime; memset(&st_DBTime, '\0', sizeof(XENGINE_DBTIMERELEASE)); - memset(&st_LibTime, '\0', sizeof(XENGINE_LIBTIMER)); + memset(&st_LibTime, '\0', sizeof(XENGINE_LIBTIME)); st_DBTime.nIDMsg = st_DBQueue.nQueueSerial; st_DBTime.nIDTime = st_MQProtocol.nPubTime; _tcsxcpy(st_DBTime.tszQueueName, st_DBQueue.tszQueueName); - BaseLib_OperatorTime_TTimeToStuTime(st_MQProtocol.nPubTime, &st_LibTime); - BaseLib_OperatorTime_TimeToStr(st_DBQueue.tszQueuePublishTime, NULL, true, &st_LibTime); + BaseLib_Time_TTimeToStuTime(st_MQProtocol.nPubTime, &st_LibTime); + BaseLib_Time_TimeToStr(st_DBQueue.tszQueuePublishTime, NULL, true, &st_LibTime); DBModule_MQUser_TimeInsert(&st_DBTime); } if (!DBModule_MQData_Modify(&st_DBQueue)) { - pSt_ProtocolHdr->wReserve = 791; + pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_MODIFYMSG; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,修改消息:%s,序列号:%lld,失败,错误:%lX"), lpszClientType, lpszClientAddr, st_DBQueue.tszQueueName, st_DBQueue.nQueueSerial, DBModule_GetLastError()); return false; } pSt_ProtocolHdr->wReserve = 0; - pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPMSGMODIFY; + pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPMODIFY; ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); @@ -940,7 +964,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC ProtocolModule_Packet_UNReadInsert(xhUNRead, ppSt_UserKey[i]->tszKeyName, nDBCount); } ProtocolModule_Packet_UNReadDelete(xhUNRead, tszSDBuffer, &nSDLen); - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_UserKey, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSt_UserKey, nListCount); XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("%s消息端:%s,请求未读消息成功,用户名:%s,发送未读消息成功,发送的主题个数:%d"), lpszClientType, lpszClientAddr, tszUserName, nListCount); } diff --git a/XEngine_Source/XEngine_MQServiceApp/MQService_Task.cpp b/XEngine_Source/XEngine_MQServiceApp/MQService_Task.cpp index d70bfcb..7b13e65 100644 --- a/XEngine_Source/XEngine_MQServiceApp/MQService_Task.cpp +++ b/XEngine_Source/XEngine_MQServiceApp/MQService_Task.cpp @@ -47,7 +47,7 @@ void CALLBACK MessageQueue_CBTask_TimePublish(XENGINE_DBTIMERELEASE* pSt_DBInfo, ProtocolModule_Packet_Common(nNetType, &st_ProtocolHdr, &st_MQProtocol, tszMsgBuffer, &nMsgLen, st_DBInfo.tszMsgBuffer, st_DBInfo.nMsgLen); XEngine_MQXService_Send(tszUserAddr, tszMsgBuffer, nMsgLen, nNetType); } - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListUser, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSt_ListUser, nListCount); if (st_DBConfig.st_MQUser.st_UserTime.bPubClear) { @@ -61,28 +61,39 @@ void CALLBACK MessageQueue_CBTask_TimePublish(XENGINE_DBTIMERELEASE* pSt_DBInfo, } XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("定时任务,消息主题:%s,序列:%lld,定时任务分发成功,客户端个数:%d"), pSt_DBInfo->tszQueueName, pSt_DBInfo->nIDMsg, nListCount); } -void CALLBACK MessageQueue_CBTask_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE enMemoryType, bool bSuccess, size_t nListCount, XENGINE_DBMESSAGEQUEUE* pSt_DBInfo, XPVOID lParam) +void CALLBACK MessageQueue_CBTask_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE enMemoryType, bool bSuccess, size_t nListCount, XPVOID pSt_DBInfo, XPVOID lParam) { if (ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_QUERY == enMemoryType) { if (bSuccess) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("高速缓存,消息主题:%s,序列:%lld,删除过期缓存成功,缓存剩余队列:%ld"), pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial, nListCount); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("高速缓存,消息主题:%s,序列:%lld,删除过期缓存成功,缓存剩余队列:%ld"), ((XENGINE_DBMESSAGEQUEUE*)pSt_DBInfo)->tszQueueName, ((XENGINE_DBMESSAGEQUEUE*)pSt_DBInfo)->nQueueSerial, nListCount); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("高速缓存,消息主题:%s,序列:%lld,删除过期缓存成功,缓存剩余队列:%ld"), pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial, nListCount); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("高速缓存,消息主题:%s,序列:%lld,删除过期缓存成功,缓存剩余队列:%ld"), ((XENGINE_DBMESSAGEQUEUE*)pSt_DBInfo)->tszQueueName, ((XENGINE_DBMESSAGEQUEUE*)pSt_DBInfo)->nQueueSerial, nListCount); } } else if (ENUM_MEMORYCACHE_CALLBACK_TYPE_DATA_INSERT == enMemoryType) { if (bSuccess) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("高速缓存,消息主题:%s,序列:%lld,插入缓存队列到数据库成功,缓存剩余队列:%ld"), pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial, nListCount); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("高速缓存,消息主题:%s,序列:%lld,插入缓存队列到数据库成功,缓存剩余队列:%ld"), ((XENGINE_DBMESSAGEQUEUE*)pSt_DBInfo)->tszQueueName, ((XENGINE_DBMESSAGEQUEUE*)pSt_DBInfo)->nQueueSerial, nListCount); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("高速缓存,消息主题:%s,序列:%lld,插入缓存队列到数据库失败,缓存剩余队列:%ld"), pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial, nListCount); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("高速缓存,消息主题:%s,序列:%lld,插入缓存队列到数据库失败,缓存剩余队列:%ld"), ((XENGINE_DBMESSAGEQUEUE*)pSt_DBInfo)->tszQueueName, ((XENGINE_DBMESSAGEQUEUE*)pSt_DBInfo)->nQueueSerial, nListCount); + } + } + else if (ENUM_MEMORYCACHE_CALLBACK_TYPE_USER_QUERY == enMemoryType) + { + if (bSuccess) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("高速缓存,用户:%s,删除过期缓存成功,缓存剩余队列:%ld"), ((XENGINE_PROTOCOL_USERINFO*)pSt_DBInfo)->tszUserName, nListCount); + } + else + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("高速缓存,用户:%s,删除过期缓存失败,缓存剩余队列:%ld"), ((XENGINE_PROTOCOL_USERINFO*)pSt_DBInfo)->tszUserName, nListCount); } } } \ No newline at end of file diff --git a/XEngine_Source/XEngine_MQServiceApp/MQService_Task.h b/XEngine_Source/XEngine_MQServiceApp/MQService_Task.h index b92c117..2f5f5a5 100644 --- a/XEngine_Source/XEngine_MQServiceApp/MQService_Task.h +++ b/XEngine_Source/XEngine_MQServiceApp/MQService_Task.h @@ -1,4 +1,4 @@ #pragma once void CALLBACK MessageQueue_CBTask_TimePublish(XENGINE_DBTIMERELEASE* pSt_DBInfo, XPVOID lParam); -void CALLBACK MessageQueue_CBTask_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE enMemoryType, bool bSuccess, size_t nListCount, XENGINE_DBMESSAGEQUEUE* pSt_DBInfo, XPVOID lParam); \ No newline at end of file +void CALLBACK MessageQueue_CBTask_MemoryCache(ENUM_MEMORYCACHE_CALLBACK_TYPE enMemoryType, bool bSuccess, size_t nListCount, XPVOID pSt_DBInfo, XPVOID lParam); \ No newline at end of file diff --git a/XEngine_Source/XEngine_MQServiceApp/MQService_WSTask.cpp b/XEngine_Source/XEngine_MQServiceApp/MQService_WSTask.cpp index 9c58b05..e85eeda 100644 --- a/XEngine_Source/XEngine_MQServiceApp/MQService_WSTask.cpp +++ b/XEngine_Source/XEngine_MQServiceApp/MQService_WSTask.cpp @@ -24,11 +24,11 @@ XHTHREAD CALLBACK MessageQueue_WebsocketThread(XPVOID lParam) if (RfcComponents_WSPacket_GetMemoryEx(xhWSPacket, ppSst_ListAddr[i]->tszClientAddr, &ptszMsgBuffer, &nMsgLen, &enOPCode)) { MessageQueue_Websocket_Handle(ppSst_ListAddr[i]->tszClientAddr, ptszMsgBuffer, nMsgLen, enOPCode); - BaseLib_OperatorMemory_FreeCStyle((VOID**)&ptszMsgBuffer); + BaseLib_Memory_FreeCStyle((VOID**)&ptszMsgBuffer); } } } - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSst_ListAddr, nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSst_ListAddr, nListCount); } return 0; } diff --git a/XEngine_Source/XEngine_MQServiceApp/Makefile b/XEngine_Source/XEngine_MQServiceApp/Makefile index 21f212f..e6710ce 100644 --- a/XEngine_Source/XEngine_MQServiceApp/Makefile +++ b/XEngine_Source/XEngine_MQServiceApp/Makefile @@ -1,4 +1,4 @@ -CC = g++ -Wall -std=c++17 +CC = g++ -Wall -std=c++20 PLATFORM = linux PLATVER = PLATDIR = diff --git a/XEngine_Source/XEngine_MQServiceApp/XEngine_MQServiceApp.cpp b/XEngine_Source/XEngine_MQServiceApp/XEngine_MQServiceApp.cpp index d5a0f4b..5842154 100644 --- a/XEngine_Source/XEngine_MQServiceApp/XEngine_MQServiceApp.cpp +++ b/XEngine_Source/XEngine_MQServiceApp/XEngine_MQServiceApp.cpp @@ -45,6 +45,7 @@ void ServiceApp_Stop(int signo) DBModule_MQData_Destory(); DBModule_MQUser_Destory(); MemoryCache_DBData_Destory(); + MemoryCache_DBUser_Destory(); SessionModule_Client_Destory(); HelpComponents_XLog_Destroy(xhLog); @@ -91,7 +92,7 @@ LONG WINAPI Coredump_ExceptionFilter(EXCEPTION_POINTERS* pExceptionPointers) static int i = 0; XCHAR tszFileStr[MAX_PATH] = {}; XCHAR tszTimeStr[128] = {}; - BaseLib_OperatorTime_TimeToStr(tszTimeStr); + BaseLib_Time_TimeToStr(tszTimeStr); _xstprintf(tszFileStr, _X("./XEngine_Coredump/dumpfile_%s_%d.dmp"), tszTimeStr, i++); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_FATAL, _X("主程序:软件崩溃,写入dump:%s"), tszFileStr); HANDLE hDumpFile = CreateFileA(tszFileStr, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); @@ -116,6 +117,13 @@ int main(int argc, char** argv) WSAStartup(MAKEWORD(2, 2), &st_WSAData); SetUnhandledExceptionFilter(Coredump_ExceptionFilter); +#ifndef _DEBUG + if (setlocale(LC_ALL, ".UTF8") == NULL) + { + fprintf(stderr, "Error setting locale.\n"); + return 1; + } +#endif #endif int nRet = -1; LPCXSTR lpszHTTPMime = _X("./XEngine_Config/HttpMime.types"); @@ -168,16 +176,29 @@ int main(int argc, char** argv) if (st_ServiceCfg.st_XMemory.bDataQueryEnable || st_ServiceCfg.st_XMemory.bDataInsertEnable) { - if (!MemoryCache_DBData_Init(st_ServiceCfg.st_XMemory.nTimeLast, st_ServiceCfg.st_XMemory.nTimeStart, MessageQueue_CBTask_MemoryCache)) + if (!MemoryCache_DBData_Init(st_ServiceCfg.st_XMemory.nTimeLast, st_ServiceCfg.st_XMemory.nTimeCount, MessageQueue_CBTask_MemoryCache)) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化消息内容高速缓存服务失败,错误:%lX"), MemoryCache_GetLastError()); + goto NETSERVICEEXIT; + } + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化消息内容高速缓存服务成功,更新最大时间:%d,存储最大时间:%d"), st_ServiceCfg.st_XMemory.nTimeLast, st_ServiceCfg.st_XMemory.nTimeCount); + } + else + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,检测到没有启用消息内容高速缓存服务"), st_ServiceCfg.st_XMemory.nTimeLast, st_ServiceCfg.st_XMemory.nTimeCount); + } + if (st_ServiceCfg.st_XMemory.bUserQueryEnable) + { + if (!MemoryCache_DBUser_Init(st_ServiceCfg.st_XMemory.nTimeLast, st_ServiceCfg.st_XMemory.nTimeCount, MessageQueue_CBTask_MemoryCache)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化高速缓存服务失败,错误:%lX"), MemoryCache_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化用户信息高速缓存服务失败,错误:%lX"), MemoryCache_GetLastError()); goto NETSERVICEEXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化高速缓存服务成功,更新最大时间:%d,存储最大时间:%d"), st_ServiceCfg.st_XMemory.nTimeLast, st_ServiceCfg.st_XMemory.nTimeStart); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化用户信息高速缓存服务成功,更新最大时间:%d,存储最大时间:%d"), st_ServiceCfg.st_XMemory.nTimeLast, st_ServiceCfg.st_XMemory.nTimeCount); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,检测到没有启用高速缓存服务"), st_ServiceCfg.st_XMemory.nTimeLast, st_ServiceCfg.st_XMemory.nTimeStart); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,检测到没有启用用户信息高速缓存服务"), st_ServiceCfg.st_XMemory.nTimeLast, st_ServiceCfg.st_XMemory.nTimeCount); } if (!bIsTest) @@ -187,7 +208,7 @@ int main(int argc, char** argv) XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化消息数据数据库失败,错误:%lX"), DBModule_GetLastError()); goto NETSERVICEEXIT; } - if (!DBModule_MQUser_Init((DATABASE_MYSQL_CONNECTINFO*)&st_ServiceCfg.st_XSql, MessageQueue_CBTask_TimePublish)) + if (!DBModule_MQUser_Init((DATABASE_MYSQL_CONNECTINFO*)&st_ServiceCfg.st_XSql, st_ServiceCfg.st_XMemory.bUserQueryEnable, MessageQueue_CBTask_TimePublish)) { XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化消息用户数据库失败,错误:%lX"), DBModule_GetLastError()); goto NETSERVICEEXIT; @@ -223,7 +244,7 @@ int main(int argc, char** argv) NetCore_TCPXCore_RegisterCallBackEx(xhTCPSocket, MessageQueue_Callback_TCPLogin, MessageQueue_Callback_TCPRecv, MessageQueue_Callback_TCPLeave); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,注册TCP网络事件成功")); //任务池 - BaseLib_OperatorMemory_Malloc((XPPPMEM)&ppSt_ListTCPParam, st_ServiceCfg.st_XMax.nTCPThread, sizeof(THREADPOOL_PARAMENT)); + BaseLib_Memory_Malloc((XPPPMEM)&ppSt_ListTCPParam, st_ServiceCfg.st_XMax.nTCPThread, sizeof(THREADPOOL_PARAMENT)); for (int i = 0; i < st_ServiceCfg.st_XMax.nTCPThread; i++) { int* pInt_Pos = new int; @@ -265,7 +286,7 @@ int main(int argc, char** argv) NetCore_TCPXCore_RegisterCallBackEx(xhHTTPSocket, MessageQueue_Callback_HttpLogin, MessageQueue_Callback_HttpRecv, MessageQueue_Callback_HttpLeave); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,注册HTTP网络事件成功")); - BaseLib_OperatorMemory_Malloc((XPPPMEM)&ppSt_ListHTTPParam, st_ServiceCfg.st_XMax.nHttpThread, sizeof(THREADPOOL_PARAMENT)); + BaseLib_Memory_Malloc((XPPPMEM)&ppSt_ListHTTPParam, st_ServiceCfg.st_XMax.nHttpThread, sizeof(THREADPOOL_PARAMENT)); for (int i = 0; i < st_ServiceCfg.st_XMax.nHttpThread; i++) { int* pInt_Pos = new int; @@ -307,7 +328,7 @@ int main(int argc, char** argv) NetCore_TCPXCore_RegisterCallBackEx(xhWSSocket, MessageQueue_Callback_WSLogin, MessageQueue_Callback_WSRecv, MessageQueue_Callback_WSLeave); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,注册Websocket网络事件成功")); - BaseLib_OperatorMemory_Malloc((XPPPMEM)&ppSt_ListWSParam, st_ServiceCfg.st_XMax.nWSThread, sizeof(THREADPOOL_PARAMENT)); + BaseLib_Memory_Malloc((XPPPMEM)&ppSt_ListWSParam, st_ServiceCfg.st_XMax.nWSThread, sizeof(THREADPOOL_PARAMENT)); for (int i = 0; i < st_ServiceCfg.st_XMax.nWSThread; i++) { int* pInt_Pos = new int; @@ -348,7 +369,7 @@ int main(int argc, char** argv) NetCore_TCPXCore_RegisterCallBackEx(xhMQTTSocket, MessageQueue_Callback_MQTTLogin, MessageQueue_Callback_MQTTRecv, MessageQueue_Callback_MQTTLeave); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,注册MQTT网络事件成功")); - BaseLib_OperatorMemory_Malloc((XPPPMEM)&ppSt_ListMQTTParam, st_ServiceCfg.st_XMax.nMQTTThread, sizeof(THREADPOOL_PARAMENT)); + BaseLib_Memory_Malloc((XPPPMEM)&ppSt_ListMQTTParam, st_ServiceCfg.st_XMax.nMQTTThread, sizeof(THREADPOOL_PARAMENT)); for (int i = 0; i < st_ServiceCfg.st_XMax.nMQTTThread; i++) { int* pInt_Pos = new int; @@ -394,7 +415,7 @@ int main(int argc, char** argv) XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,信息报告给API服务器没有启用")); } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("所有服务成功启动,服务运行中,XEngine版本:%s%s,发行版本次数:%d,当前运行版本:%s。。。"), BaseLib_OperatorVer_XNumberStr(), BaseLib_OperatorVer_XTypeStr(), st_ServiceCfg.st_XVer.pStl_ListStorage->size(), st_ServiceCfg.st_XVer.pStl_ListStorage->front().c_str()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("所有服务成功启动,服务运行中,XEngine版本:%s%s,发行版本次数:%d,当前运行版本:%s。。。"), BaseLib_Version_XNumberStr(), BaseLib_Version_XTypeStr(), st_ServiceCfg.st_XVer.pStl_ListStorage->size(), st_ServiceCfg.st_XVer.pStl_ListStorage->front().c_str()); while (true) { @@ -435,6 +456,7 @@ int main(int argc, char** argv) DBModule_MQData_Destory(); DBModule_MQUser_Destory(); MemoryCache_DBData_Destory(); + MemoryCache_DBUser_Destory(); SessionModule_Client_Destory(); HelpComponents_XLog_Destroy(xhLog); diff --git a/XEngine_Source/XEngine_MQServiceApp/XEngine_MQServiceApp.vcxproj b/XEngine_Source/XEngine_MQServiceApp/XEngine_MQServiceApp.vcxproj index 02d9042..1923395 100644 --- a/XEngine_Source/XEngine_MQServiceApp/XEngine_MQServiceApp.vcxproj +++ b/XEngine_Source/XEngine_MQServiceApp/XEngine_MQServiceApp.vcxproj @@ -37,20 +37,20 @@ false v143 true - MultiByte + Unicode Application true v143 - MultiByte + Unicode Application false v143 true - MultiByte + Unicode @@ -97,6 +97,8 @@ WIN32;_DEBUG;_CONSOLE;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true 4819 + stdcpp20 + stdc17 Console @@ -113,6 +115,9 @@ true MultiThreaded 4819 + stdcpp20 + stdc17 + /utf-8 %(AdditionalOptions) Console @@ -127,6 +132,8 @@ true _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true + stdcpp20 + stdc17 Console @@ -143,6 +150,9 @@ true MultiThreaded 4819 + stdcpp20 + stdc17 + /utf-8 %(AdditionalOptions) Console diff --git a/XEngine_Source/XQueue_ProtocolHdr.h b/XEngine_Source/XQueue_ProtocolHdr.h index eebd61f..d03b55f 100644 --- a/XEngine_Source/XQueue_ProtocolHdr.h +++ b/XEngine_Source/XQueue_ProtocolHdr.h @@ -22,22 +22,24 @@ #define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPPOST 0x7001 //投递包回复 #define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQGET 0x7002 //获取包请求 #define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPGET 0x7003 //获取包回复 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQNUMBER 0x7004 //请求消息队列编号信息 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPNUMBER 0x7005 //回复 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQUNREAD 0x7006 //请求未读消息 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPUNREAD 0x7007 //响应未读消息 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICCREATE 0x7010 //主题创建请求 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICCREATE 0x7011 //主题创建回复 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICDELETE 0x7012 //主题删除请求 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICDELETE 0x7013 //主题删除回复 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICMODIFY 0x7014 //主题名修改请求 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICMODIFY 0x7015 //主题名修改回复 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICBIND 0x7016 //请求主题绑定操作 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICBIND 0x7017 //回复 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICUNBIND 0x7018 //请求主题解绑操作 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICUNBIND 0x7019 //回复 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQMSGMODIFY 0x7020 //消息修改请求 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPMSGMODIFY 0x7021 //消息修改回复 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQDELETE 0x7004 //消息删除请求 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPDELETE 0x7005 //消息删除回复 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQMODIFY 0x7006 //消息修改请求 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPMODIFY 0x7007 //消息修改回复 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQNUMBER 0x7008 //请求消息队列编号信息 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPNUMBER 0x7009 //回复 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQUNREAD 0x7010 //请求未读消息 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPUNREAD 0x7011 //响应未读消息 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICCREATE 0x7100 //主题创建请求 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICCREATE 0x7101 //主题创建回复 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICDELETE 0x7102 //主题删除请求 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICDELETE 0x7103 //主题删除回复 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICMODIFY 0x7104 //主题名修改请求 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICMODIFY 0x7105 //主题名修改回复 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICBIND 0x7106 //请求主题绑定操作 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICBIND 0x7107 //回复 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICUNBIND 0x7108 //请求主题解绑操作 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICUNBIND 0x7109 //回复 //用户协议 #define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQUSERLOG 0x7020 //用户登录 #define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPUSERLOG 0x7021 @@ -50,6 +52,36 @@ //Only TCP and WEBSOCKET #define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_MSGNOTIFY 0x70A0 //消息通知 /////////////////////////////////////////////////////////////////////////// +// 协议错误定义 +/////////////////////////////////////////////////////////////////////////// +#define ERROR_XENGINE_MESSAGE_AUTH_LOGGED 0x1001 //已经登陆过了 +#define ERROR_XENGINE_MESSAGE_AUTH_HTTP 0x1002 //HTTP PASS验证失败 +#define ERROR_XENGINE_MESSAGE_AUTH_USERPASS 0x1003 //用户或者密码错误 +#define ERROR_XENGINE_MESSAGE_AUTH_NOTLOGIN 0x1004 //没有登陆,禁止操作 +#define ERROR_XENGINE_MESSAGE_AUTH_APIREG 0x1005 //HTTP 远程注册失败 +#define ERROR_XENGINE_MESSAGE_AUTH_EXISTED 0x1006 //用户已经存在 +#define ERROR_XENGINE_MESSAGE_AUTH_REGISTER 0x1007 //用户注册失败,数据错误 +#define ERROR_XENGINE_MESSAGE_AUTH_APIDEL 0x1008 //HTTP API删除失败 +#define ERROR_XENGINE_MESSAGE_AUTH_DELETE 0x1009 //本地删除失败 + +#define ERROR_XENGINE_MESSAGE_XMQ_EXISTED 0x2001 //消息存在 +#define ERROR_XENGINE_MESSAGE_XMQ_INSERT 0x2002 //插入数据库失败 +#define ERROR_XENGINE_MESSAGE_XMQ_MSGQUERY 0x2003 //查询消息失败 +#define ERROR_XENGINE_MESSAGE_XMQ_BELONG 0x2004 //指定用户消息,无权使用 +#define ERROR_XENGINE_MESSAGE_XMQ_TIMEOUT 0x2005 //消息超时,无权使用 +#define ERROR_XENGINE_MESSAGE_XMQ_PUBTIME 0x2006 //定时消息,无权使用 +#define ERROR_XENGINE_MESSAGE_XMQ_KEYQUERY 0x2007 //查询绑定消息失败 +#define ERROR_XENGINE_MESSAGE_XMQ_SERIAL 0x2008 //消息序号错误 +#define ERROR_XENGINE_MESSAGE_XMQ_CREATEKEY 0x2009 //创建消息KEY失败 +#define ERROR_XENGINE_MESSAGE_XMQ_BINDOWNER 0x2010 //绑定所有者失败 +#define ERROR_XENGINE_MESSAGE_XMQ_DELOWNER 0x2011 //删除所有者失败 +#define ERROR_XENGINE_MESSAGE_XMQ_KEYUP 0x2012 //更新KEY失败 +#define ERROR_XENGINE_MESSAGE_XMQ_BINDKEY 0x2013 //绑定KEY失败 +#define ERROR_XENGINE_MESSAGE_XMQ_DELKEY 0x2014 //删除KEY失败 +#define ERROR_XENGINE_MESSAGE_XMQ_QUERYOWNER 0x2015 //查询所有者失败 +#define ERROR_XENGINE_MESSAGE_XMQ_MODIFYTOPIC 0x2016 //修改主题失败 +#define ERROR_XENGINE_MESSAGE_XMQ_MODIFYMSG 0x2017 //修改消息失败 +/////////////////////////////////////////////////////////////////////////// // 导出的数据结构 /////////////////////////////////////////////////////////////////////////// #pragma pack(push)