forked from yydcaib/TCPClient
对数据的发送和处理做了一些完善
This commit is contained in:
parent
2967def5b7
commit
0676ee2391
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 6.0.2, 2023-01-06T11:03:01. -->
|
<!-- Written by QtCreator 6.0.2, 2023-01-06T22:44:04. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
@ -85,176 +85,13 @@
|
||||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="CppEditor.QuickFix">
|
||||||
|
<value type="bool" key="UseGlobalSettings">true</value>
|
||||||
|
</valuemap>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value type="QString" key="DeviceType">Desktop</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.2.3 MinGW 64-bit</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.2.3 MinGW 64-bit</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.623.win64_mingw_kit</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
|
||||||
<value type="int" key="EnableQmlDebugging">0</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\25761\Desktop\build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-Debug</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-Debug</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
|
||||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
|
||||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
|
||||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\25761\Desktop\build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-Release</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-Release</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
|
||||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
|
||||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
|
||||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
|
||||||
<value type="int" key="QtQuickCompiler">0</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
|
||||||
<value type="int" key="EnableQmlDebugging">0</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\25761\Desktop\build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-Profile</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-Profile</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
|
||||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
|
||||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
|
||||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
|
||||||
<value type="int" key="QtQuickCompiler">0</value>
|
|
||||||
<value type="int" key="SeparateDebugInfo">0</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
|
||||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
|
||||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
|
||||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">TcpClient2</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/25761/Desktop/tcpclient/TcpClient.pro</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/25761/Desktop/tcpclient/TcpClient.pro</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
|
||||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-Debug</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.Target.1</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
<value type="QString" key="DeviceType">Desktop</value>
|
<value type="QString" key="DeviceType">Desktop</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.2.3 MSVC2019 64bit</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.2.3 MSVC2019 64bit</value>
|
||||||
|
@ -265,8 +102,8 @@
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
<value type="int" key="EnableQmlDebugging">0</value>
|
<value type="int" key="EnableQmlDebugging">0</value>
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\25761\Desktop\build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug</value>
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\25761\Desktop\Error-in-"-Util.asciify("build-C:\Users\25761\Desktop\tcpclient\TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug")":-SyntaxError:-Expected-token-`)'</value>
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug</value>
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/25761/Desktop/Error-in-"-Util.asciify("build-C:/Users/25761/Desktop/tcpclient/TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug")":-SyntaxError:-Expected-token-`)'</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
@ -304,8 +141,8 @@
|
||||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\25761\Desktop\build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Release</value>
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\25761\Desktop\Error-in-"-Util.asciify("build-C:\Users\25761\Desktop\tcpclient\TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Release")":-SyntaxError:-Expected-token-`)'</value>
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Release</value>
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/25761/Desktop/Error-in-"-Util.asciify("build-C:/Users/25761/Desktop/tcpclient/TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Release")":-SyntaxError:-Expected-token-`)'</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
@ -345,8 +182,8 @@
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||||
<value type="int" key="EnableQmlDebugging">0</value>
|
<value type="int" key="EnableQmlDebugging">0</value>
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\25761\Desktop\build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Profile</value>
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\25761\Desktop\Error-in-"-Util.asciify("build-C:\Users\25761\Desktop\tcpclient\TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Profile")":-SyntaxError:-Expected-token-`)'</value>
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Profile</value>
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/25761/Desktop/Error-in-"-Util.asciify("build-C:/Users/25761/Desktop/tcpclient/TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Profile")":-SyntaxError:-Expected-token-`)'</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
@ -406,20 +243,21 @@
|
||||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/25761/Desktop/TcpClient/TcpClient.pro</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:\Users\25761\Desktop\tcpclient\TcpClient.pro</value>
|
||||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/25761/Desktop/TcpClient/TcpClient.pro</value>
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:\Users\25761\Desktop\tcpclient\TcpClient.pro</value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/25761/Desktop/Error-in-"-Util.asciify("build-C:/Users/25761/Desktop/tcpclient/TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug")":-SyntaxError:-Expected-token-`)'</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||||
<value type="qlonglong">2</value>
|
<value type="qlonglong">1</value>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "datamanager.h"
|
#include "datamanager.h"
|
||||||
|
//DataManager* DataManager::p_this;
|
||||||
DataManager::DataManager(QObject *parent)
|
DataManager::DataManager(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
{
|
{
|
||||||
|
@ -7,9 +7,11 @@ DataManager::DataManager(QObject *parent)
|
||||||
tcpclient = TCPClient::getInstance();
|
tcpclient = TCPClient::getInstance();
|
||||||
connect(tcpclient,&TCPClient::TCPClientConnected,this,&DataManager::TCPClientConnected);
|
connect(tcpclient,&TCPClient::TCPClientConnected,this,&DataManager::TCPClientConnected);
|
||||||
connect(tcpclient,&TCPClient::TCPClientDisconnected,this,&DataManager::TCPClientDisconnected);
|
connect(tcpclient,&TCPClient::TCPClientDisconnected,this,&DataManager::TCPClientDisconnected);
|
||||||
|
connect(tcpclient,&TCPClient::recv_data,this,&DataManager::recv_from_server);
|
||||||
tcpclient->configAndrun();
|
tcpclient->configAndrun();
|
||||||
tcpclient->setCallBack(recv_from_server);
|
//tcpclient->setCallBack(recv_from_server);
|
||||||
protocol = Protocol::getInstance();
|
protocol = Protocol::getInstance();
|
||||||
|
//p_this = this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,40 +32,111 @@ void DataManager::TCPClientDisconnected()
|
||||||
{
|
{
|
||||||
connect_flag = false;
|
connect_flag = false;
|
||||||
qDebug() << "emit disconnect_from_server successfully";
|
qDebug() << "emit disconnect_from_server successfully";
|
||||||
|
//emit p_this->disconnect_from_server();
|
||||||
emit disconnect_from_server();
|
emit disconnect_from_server();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::recv_from_server(QString &peerAddress, quint16 peerPort, QByteArray &data)
|
void DataManager::recv_from_server(QByteArray &data)
|
||||||
{
|
{
|
||||||
//
|
QByteArray data_decrypt;
|
||||||
|
data_decrypt = protocol->data_decrypt(data);
|
||||||
|
QJsonDocument json_data = QJsonDocument::fromJson(data_decrypt);
|
||||||
|
if (json_data["type"] == "message")
|
||||||
|
{
|
||||||
|
QString data,sendname;
|
||||||
|
sendname = json_data["sendname"].toString();
|
||||||
|
data = json_data["data"].toString();
|
||||||
|
emit update_text(sendname,data);
|
||||||
|
}
|
||||||
|
else if (json_data["type"] == "file")
|
||||||
|
{
|
||||||
|
QString filename,file_data,sendname;
|
||||||
|
sendname = json_data["sendname"].toString();
|
||||||
|
filename = json_data["name"].toString();
|
||||||
|
file_data = json_data["data"].toString();
|
||||||
|
emit update_file(sendname,filename,file_data);
|
||||||
|
}
|
||||||
|
else if (json_data["type"] == "online_users")
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
QList<QString> online_users;
|
||||||
|
count = json_data["count"].toInt();
|
||||||
|
online_users = json_data["users"].toVariant().toStringList();
|
||||||
|
emit update_users(count,online_users);
|
||||||
|
}
|
||||||
|
else if (json_data["type"] == "response")
|
||||||
|
{
|
||||||
|
if(json_data["action"] == "register")
|
||||||
|
{
|
||||||
|
bool register_flag;
|
||||||
|
register_flag = json_data["content"].toBool();
|
||||||
|
emit signup_response(register_flag);
|
||||||
|
}
|
||||||
|
else if(json_data["action"] == "signin")
|
||||||
|
{
|
||||||
|
bool signin_flag;
|
||||||
|
signin_flag = json_data["content"].toBool();
|
||||||
|
emit signin_response(signin_flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::Register(QString username,QString password)
|
void DataManager::Register(QString username,QString password)
|
||||||
{
|
{
|
||||||
|
QByteArray data,data_encrypt;
|
||||||
|
data = protocol->data_maker(Protocol::REQUEST,QString("register"),QList<QString>{username,password});
|
||||||
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
|
tcpclient->sendToserver(data_encrypt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::signin_request(QString username,QString password)
|
void DataManager::signin_request(QString username,QString password)
|
||||||
{
|
{
|
||||||
|
QByteArray data,data_encrypt;
|
||||||
|
data = protocol->data_maker(Protocol::REQUEST,QString("signin"),QList<QString>{username,password});
|
||||||
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
|
tcpclient->sendToserver(data_encrypt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::send_text(QString text)
|
void DataManager::send_text(QString sendname,QString text)
|
||||||
{
|
{
|
||||||
|
QByteArray data,data_encrypt;
|
||||||
|
data = protocol->data_maker(Protocol::MESSAGE,sendname,text);
|
||||||
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
|
tcpclient->sendToserver(data_encrypt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::send_file_to_all(QByteArray file)
|
void DataManager::send_to_user(QString sendname,QString to_user,QString text)
|
||||||
{
|
{
|
||||||
|
QByteArray data,data_encrypt;
|
||||||
|
data = protocol->data_maker(Protocol::MESSAGE,sendname,to_user,text);
|
||||||
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
|
tcpclient->sendToserver(data_encrypt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::send_file_private(QByteArray file,QString name)
|
void DataManager::send_file_to_all(QString sendname,QString filename,QByteArray file)
|
||||||
{
|
{
|
||||||
|
QByteArray data,data_encrypt;
|
||||||
|
data = protocol->data_maker(Protocol::FILE,sendname,filename,file);
|
||||||
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
|
tcpclient->sendToserver(data_encrypt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataManager::send_file_private(QString sendname,QString filename,QByteArray file,QString name)
|
||||||
|
{
|
||||||
|
QByteArray data,data_encrypt;
|
||||||
|
data = protocol->data_maker(Protocol::FILE,name,sendname,filename,file);
|
||||||
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
|
tcpclient->sendToserver(data_encrypt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::account_cancellation(QString username)
|
void DataManager::account_cancellation(QString username)
|
||||||
{
|
{
|
||||||
|
QByteArray data,data_encrypt;
|
||||||
|
data = protocol->data_maker(Protocol::REQUEST,QString("cancellation"),username);
|
||||||
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
|
tcpclient->sendToserver(data_encrypt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "tcpclient.h"
|
#include "tcpclient.h"
|
||||||
|
@ -15,11 +16,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DataManager(QObject *parent = nullptr);
|
explicit DataManager(QObject *parent = nullptr);
|
||||||
static void recv_from_server(QString &peerAddress,quint16 peerPort,QByteArray &data);
|
//static void recv_from_server(QString &peerAddress,quint16 peerPort,QByteArray &data);
|
||||||
|
//static Protocol *protocol;
|
||||||
|
//static DataManager *p_this;
|
||||||
Protocol *protocol;
|
Protocol *protocol;
|
||||||
TCPClient *tcpclient;
|
TCPClient *tcpclient;
|
||||||
QString username;
|
|
||||||
QString password;
|
|
||||||
bool connect_flag = false;
|
bool connect_flag = false;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -27,6 +28,10 @@ signals:
|
||||||
void disconnect_from_server();
|
void disconnect_from_server();
|
||||||
void signin_response(bool result);
|
void signin_response(bool result);
|
||||||
void signup_response(bool result);
|
void signup_response(bool result);
|
||||||
|
void update_text(QString sendname,QString data);
|
||||||
|
void update_file(QString sendname,QString filename,QString file_data);
|
||||||
|
void update_users(int count,QList<QString>online_users);
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/*******ui界面********/
|
/*******ui界面********/
|
||||||
|
@ -34,14 +39,16 @@ public slots:
|
||||||
void signin_request(QString username,QString password);
|
void signin_request(QString username,QString password);
|
||||||
|
|
||||||
/******MAINWIDGET*****/
|
/******MAINWIDGET*****/
|
||||||
void send_text(QString text);
|
void send_text(QString sendname,QString text);
|
||||||
void send_file_to_all(QByteArray file);
|
void send_to_user(QString sendname,QString to_user,QString text);
|
||||||
void send_file_private(QByteArray file,QString name);
|
void send_file_to_all(QString sendname,QString filename,QByteArray file);
|
||||||
|
void send_file_private(QString sendname,QString filename,QByteArray file,QString name);
|
||||||
void account_cancellation(QString username);
|
void account_cancellation(QString username);
|
||||||
|
|
||||||
/******TCPClient******/
|
/******TCPClient******/
|
||||||
void TCPClientConnected();
|
void TCPClientConnected();
|
||||||
void TCPClientDisconnected();
|
void TCPClientDisconnected();
|
||||||
|
void recv_from_server(QByteArray &data);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
25
login.cpp
25
login.cpp
|
@ -167,9 +167,13 @@ void Login::signin_response(bool result)
|
||||||
{
|
{
|
||||||
mainwidget = new MainWidget(user);
|
mainwidget = new MainWidget(user);
|
||||||
connect(mainwidget,&MainWidget::send_text,datamanager,&DataManager::send_text);
|
connect(mainwidget,&MainWidget::send_text,datamanager,&DataManager::send_text);
|
||||||
|
connect(mainwidget,&MainWidget::send_to_user,datamanager,&DataManager::send_to_user);
|
||||||
connect(mainwidget,&MainWidget::send_file_private,datamanager,&DataManager::send_file_private);
|
connect(mainwidget,&MainWidget::send_file_private,datamanager,&DataManager::send_file_private);
|
||||||
connect(mainwidget,&MainWidget::send_file_to_all,datamanager,&DataManager::send_file_to_all);
|
connect(mainwidget,&MainWidget::send_file_to_all,datamanager,&DataManager::send_file_to_all);
|
||||||
connect(mainwidget,&MainWidget::account_cancellation,datamanager,&DataManager::account_cancellation);
|
connect(mainwidget,&MainWidget::account_cancellation,datamanager,&DataManager::account_cancellation);
|
||||||
|
connect(datamanager,&DataManager::update_text,mainwidget,&MainWidget::update_text);
|
||||||
|
connect(datamanager,&DataManager::update_file,mainwidget,&MainWidget::update_file);
|
||||||
|
connect(datamanager,&DataManager::update_users,mainwidget,&MainWidget::update_users);
|
||||||
connect(mainwidget,&MainWidget::exit_client,this,&Login::exit_client);
|
connect(mainwidget,&MainWidget::exit_client,this,&Login::exit_client);
|
||||||
this->hide();
|
this->hide();
|
||||||
mainwidget->show();
|
mainwidget->show();
|
||||||
|
@ -180,16 +184,6 @@ void Login::signin_response(bool result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Login::slot_Register(QString username,QString password)
|
|
||||||
{
|
|
||||||
if(connect_flag == false)
|
|
||||||
{
|
|
||||||
QMessageBox::warning(signup, "注册失败", "尚未连接服务器!请连接服务器后重试");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit Register(username,password);
|
|
||||||
}
|
|
||||||
|
|
||||||
//等待服务器注册数据
|
//等待服务器注册数据
|
||||||
void Login::signup_response(bool result)
|
void Login::signup_response(bool result)
|
||||||
{
|
{
|
||||||
|
@ -204,6 +198,17 @@ void Login::signup_response(bool result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//注册界面按下注册按键
|
||||||
|
void Login::slot_Register(QString username,QString password)
|
||||||
|
{
|
||||||
|
if(connect_flag == false)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(signup, "注册失败", "尚未连接服务器!请连接服务器后重试");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit Register(username,password);
|
||||||
|
}
|
||||||
|
|
||||||
//连接上服务器
|
//连接上服务器
|
||||||
void Login::connected()
|
void Login::connected()
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,7 +127,18 @@ void MainWidget::on_send_btn_clicked()
|
||||||
ui->msg_edit->clear();
|
ui->msg_edit->clear();
|
||||||
QString currentTime = QTime::currentTime().toString("H:m A");
|
QString currentTime = QTime::currentTime().toString("H:m A");
|
||||||
ui->textEdit->append("<font color=\"MediumBlue\"><b>" + username + " [" + currentTime + "] :</b> " + text + "</font>");
|
ui->textEdit->append("<font color=\"MediumBlue\"><b>" + username + " [" + currentTime + "] :</b> " + text + "</font>");
|
||||||
emit send_text(text);
|
if(text[0] == '@')
|
||||||
|
{
|
||||||
|
int n = text.indexOf(' ');
|
||||||
|
QString to_user = text.mid(1,n-1);
|
||||||
|
QString insert = "tell you quietly:";
|
||||||
|
text = insert + text.mid(n,-1);
|
||||||
|
emit send_to_user(username,to_user,text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emit send_text(username,text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,8 +201,7 @@ void MainWidget::sendFile(QString filePath,QString filename,QString name)
|
||||||
//打开文件流,以写的方式打开
|
//打开文件流,以写的方式打开
|
||||||
QDataStream out(&block,QIODevice::WriteOnly);
|
QDataStream out(&block,QIODevice::WriteOnly);
|
||||||
out.setVersion(QDataStream::Qt_5_8);
|
out.setVersion(QDataStream::Qt_5_8);
|
||||||
QString command = filename+"\n";
|
|
||||||
out << command;
|
|
||||||
//将数据读取到QByteArray
|
//将数据读取到QByteArray
|
||||||
QByteArray dataOfFile = file.readAll();
|
QByteArray dataOfFile = file.readAll();
|
||||||
//关闭文件
|
//关闭文件
|
||||||
|
@ -201,15 +211,31 @@ void MainWidget::sendFile(QString filePath,QString filename,QString name)
|
||||||
|
|
||||||
if(name.isEmpty()) //群发文件
|
if(name.isEmpty()) //群发文件
|
||||||
{
|
{
|
||||||
emit send_file_to_all(block);
|
emit send_file_to_all(name,filename,block);
|
||||||
}
|
}
|
||||||
|
|
||||||
else //私发文件
|
else //私发文件
|
||||||
{
|
{
|
||||||
emit send_file_private(block,name);
|
emit send_file_private(name,filename,block,name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWidget::update_text(QString sendname,QString data)
|
||||||
|
{
|
||||||
|
QString currentTime = QTime::currentTime().toString("H:m A");
|
||||||
|
ui->textEdit->append(sendname + " [" + currentTime + "] : " + data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWidget::update_file(QString sendname,QString filename,QString file_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWidget::update_users(int count,QList<QString>online_users)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool MainWidget::eventFilter(QObject *target, QEvent *event)
|
bool MainWidget::eventFilter(QObject *target, QEvent *event)
|
||||||
{
|
{
|
||||||
if(target == ui->msg_edit) //可替换
|
if(target == ui->msg_edit) //可替换
|
||||||
|
|
17
mainwidget.h
17
mainwidget.h
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
|
#include <QList>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
@ -27,24 +28,24 @@ public:
|
||||||
bool eventFilter(QObject *target, QEvent *event);
|
bool eventFilter(QObject *target, QEvent *event);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void send_text(QString text);
|
void send_text(QString sendname,QString text);
|
||||||
void send_file_to_all(QByteArray file);
|
void send_to_user(QString sendname,QString to_user,QString test);
|
||||||
void send_file_private(QByteArray file,QString name);
|
void send_file_to_all(QString sendname,QString filename,QByteArray file);
|
||||||
|
void send_file_private(QString sendname,QString filename,QByteArray file,QString name);
|
||||||
void exit_client();
|
void exit_client();
|
||||||
void account_cancellation(QString username);
|
void account_cancellation(QString username);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_send_text_clicked();
|
void on_send_text_clicked();
|
||||||
|
|
||||||
void on_save_btn_clicked();
|
void on_save_btn_clicked();
|
||||||
|
|
||||||
void on_send_btn_clicked();
|
void on_send_btn_clicked();
|
||||||
|
|
||||||
void on_name_list_itemDoubleClicked(QListWidgetItem *item);
|
void on_name_list_itemDoubleClicked(QListWidgetItem *item);
|
||||||
|
|
||||||
void on_exit_btn_clicked();
|
void on_exit_btn_clicked();
|
||||||
|
|
||||||
void on_stop_clicked();
|
void on_stop_clicked();
|
||||||
|
public slots:
|
||||||
|
void update_text(QString sendname,QString data);
|
||||||
|
void update_file(QString sendname,QString filename,QString file_data);
|
||||||
|
void update_users(int count,QList<QString>online_users);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWidget *ui;
|
Ui::MainWidget *ui;
|
||||||
|
|
34
protocol.cpp
34
protocol.cpp
|
@ -26,24 +26,38 @@ QByteArray Protocol::data_builder(QList<any_types> &args)
|
||||||
{
|
{
|
||||||
case MESSAGE:
|
case MESSAGE:
|
||||||
{
|
{
|
||||||
if (args.length()==2)
|
if (args.length()==3)
|
||||||
{
|
{
|
||||||
data.insert("type","message");
|
data.insert("type","message");
|
||||||
data.insert("data",args[1].get_string());
|
data.insert("sendname",args[1].get_string());
|
||||||
}
|
|
||||||
else if (args.length()==3)
|
|
||||||
{
|
|
||||||
data.insert("type","message");
|
|
||||||
data.insert("to_user",args[1].get_string());
|
|
||||||
data.insert("data",args[2].get_string());
|
data.insert("data",args[2].get_string());
|
||||||
}
|
}
|
||||||
|
else if (args.length()==4)
|
||||||
|
{
|
||||||
|
data.insert("type","message");
|
||||||
|
data.insert("sendname",args[1].get_string());
|
||||||
|
data.insert("to_user",args[2].get_string());
|
||||||
|
data.insert("data",args[3].get_string());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FILE:
|
case FILE:
|
||||||
{
|
{
|
||||||
data.insert("type","file");
|
if(args.length()==4)
|
||||||
data.insert("name",args[1].get_string());
|
{
|
||||||
data.insert("data",args[2].get_string());
|
data.insert("type","file");
|
||||||
|
data.insert("sendname",args[1].get_string());
|
||||||
|
data.insert("name",args[2].get_string());
|
||||||
|
data.insert("data",args[3].get_string());
|
||||||
|
}
|
||||||
|
else if(args.length()==5)
|
||||||
|
{
|
||||||
|
data.insert("type","file");
|
||||||
|
data.insert("to_user",args[1].get_string());
|
||||||
|
data.insert("sendname",args[2].get_string());
|
||||||
|
data.insert("name",args[3].get_string());
|
||||||
|
data.insert("data",args[4].get_string());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REQUEST:
|
case REQUEST:
|
||||||
|
|
|
@ -85,6 +85,7 @@ void TCPClient::readSocket()
|
||||||
printf("TCPC Message:%.*s\n",recv.size(),(char *)recv.data());
|
printf("TCPC Message:%.*s\n",recv.size(),(char *)recv.data());
|
||||||
if (_callback != nullptr)
|
if (_callback != nullptr)
|
||||||
_callback(ip, socket.peerPort(),recv);
|
_callback(ip, socket.peerPort(),recv);
|
||||||
|
emit recv_data(recv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCPClient::setCallBack(void (*callback)(QString &mac, quint16 port, QByteArray &data))
|
void TCPClient::setCallBack(void (*callback)(QString &mac, quint16 port, QByteArray &data))
|
||||||
|
|
|
@ -12,7 +12,7 @@ public:
|
||||||
static TCPClient* getInstance();
|
static TCPClient* getInstance();
|
||||||
static void sendToserver(QByteArray &data);
|
static void sendToserver(QByteArray &data);
|
||||||
void configAndrun();
|
void configAndrun();
|
||||||
void setCallBack(void (*callback)(QString &ip, quint16 port, QByteArray &data));
|
void setCallBack(void (*callback)(QString &ip, quint16 port,QByteArray &data));
|
||||||
void setServer(QString IP, qint16 port);
|
void setServer(QString IP, qint16 port);
|
||||||
private slots:
|
private slots:
|
||||||
void readSocket();
|
void readSocket();
|
||||||
|
@ -27,10 +27,11 @@ private:
|
||||||
QString server_ip = "127.0.0.1";
|
QString server_ip = "127.0.0.1";
|
||||||
qint16 server_port = 7890;
|
qint16 server_port = 7890;
|
||||||
bool has_found = false;
|
bool has_found = false;
|
||||||
void (*_callback) (QString &ip, quint16 port, QByteArray &data)=nullptr;
|
void (*_callback) (QString &ip, quint16 port,QByteArray &data)=nullptr;
|
||||||
signals:
|
signals:
|
||||||
void TCPClientConnected();
|
void TCPClientConnected();
|
||||||
void TCPClientDisconnected();
|
void TCPClientDisconnected();
|
||||||
|
void recv_data(QByteArray data);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue