diff --git a/Lib/Net4x/HaoYueNet.ClientNetworkNet4x.dll b/Lib/Net4x/HaoYueNet.ClientNetworkNet4x.dll
new file mode 100644
index 0000000..b71c2fd
Binary files /dev/null and b/Lib/Net4x/HaoYueNet.ClientNetworkNet4x.dll differ
diff --git a/Lib/Net4x/HaoYueNet.ServerNetworkNet4x.dll b/Lib/Net4x/HaoYueNet.ServerNetworkNet4x.dll
new file mode 100644
index 0000000..f57bef1
Binary files /dev/null and b/Lib/Net4x/HaoYueNet.ServerNetworkNet4x.dll differ
diff --git a/Lib/Net4x/System.Buffers.dll b/Lib/Net4x/System.Buffers.dll
new file mode 100644
index 0000000..14e5c53
Binary files /dev/null and b/Lib/Net4x/System.Buffers.dll differ
diff --git a/Lib/Net4x/System.Memory.dll b/Lib/Net4x/System.Memory.dll
new file mode 100644
index 0000000..31486d6
Binary files /dev/null and b/Lib/Net4x/System.Memory.dll differ
diff --git a/Lib/Net4x/System.Runtime.CompilerServices.Unsafe.dll b/Lib/Net4x/System.Runtime.CompilerServices.Unsafe.dll
new file mode 100644
index 0000000..b50dbc4
Binary files /dev/null and b/Lib/Net4x/System.Runtime.CompilerServices.Unsafe.dll differ
diff --git a/NoSugarNet.ClientCore/AppNoSugarNet.cs b/NoSugarNet.ClientCore/AppNoSugarNet.cs
index 07242f0..faaaf2d 100644
--- a/NoSugarNet.ClientCore/AppNoSugarNet.cs
+++ b/NoSugarNet.ClientCore/AppNoSugarNet.cs
@@ -1,6 +1,7 @@
using NoSugarNet.ClientCore.Manager;
using NoSugarNet.ClientCore.Network;
using ServerCore.Manager;
+using static NoSugarNet.ClientCore.Manager.LogManager;
namespace NoSugarNet.ClientCore
{
@@ -25,22 +26,25 @@ namespace NoSugarNet.ClientCore
public static event OnUpdateStatusHandler OnUpdateStatus;
#endregion
- public static void Init(string IP, int port)
+ public static void Init(string IP, int port, OnLogHandler onLog = null)
{
log = new LogManager();
+ if(onLog != null)
+ LogManager.OnLog += onLog;
networkHelper = new NetworkHelper();
login = new AppLogin();
chat = new AppChat();
local = new AppLocalClient();
user = new UserDataManager();
netStatus = new NetStatus();
- networkHelper.Init(IP, port);
-
- _SpeedCheckTimeTimer = new System.Timers.Timer();
- _SpeedCheckTimeTimer.Interval = TimerInterval;
- _SpeedCheckTimeTimer.Elapsed += Checktimer_Elapsed;
- _SpeedCheckTimeTimer.AutoReset = true;
- _SpeedCheckTimeTimer.Enabled = true;
+ if (networkHelper.Init(IP, port))
+ {
+ _SpeedCheckTimeTimer = new System.Timers.Timer();
+ _SpeedCheckTimeTimer.Interval = TimerInterval;
+ _SpeedCheckTimeTimer.Elapsed += Checktimer_Elapsed;
+ _SpeedCheckTimeTimer.AutoReset = true;
+ _SpeedCheckTimeTimer.Enabled = true;
+ }
}
static void Checktimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
diff --git a/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener.cs b/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener.cs
index 58fe869..f4f4987 100644
--- a/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener.cs
+++ b/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener.cs
@@ -21,7 +21,7 @@ namespace NoSugarNet.ClientCore
private void ClientNumberChange(int num, AsyncUserToken token)
{
- Console.WriteLine("Client数发生变化");
+ AppNoSugarNet.log.Debug("Client数发生变化");
//增加连接数
if (num > 0)
{
@@ -73,7 +73,7 @@ namespace NoSugarNet.ClientCore
}
catch (Exception ex)
{
- Console.WriteLine("逻辑处理错误:" + ex.ToString());
+ AppNoSugarNet.log.Debug("逻辑处理错误:" + ex.ToString());
}
}
diff --git a/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener_Source.cs b/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener_Source.cs
index 0ed1064..40912ce 100644
--- a/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener_Source.cs
+++ b/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener_Source.cs
@@ -22,7 +22,7 @@ namespace NoSugarNet.ClientCore
private void ClientNumberChange(Socket socket)
{
- Console.WriteLine("Client数发生变化");
+ AppNoSugarNet.log.Debug("Client数发生变化");
//增加连接数
int Idx = AddDictSocket(socket);
if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInf))
@@ -83,7 +83,7 @@ namespace NoSugarNet.ClientCore
}
catch (Exception ex)
{
- Console.WriteLine("逻辑处理错误:" + ex.ToString());
+ AppNoSugarNet.log.Debug("逻辑处理错误:" + ex.ToString());
}
}
diff --git a/NoSugarNet.ClientCore/Manager/LogManager.cs b/NoSugarNet.ClientCore/Manager/LogManager.cs
index 425878d..f07fd60 100644
--- a/NoSugarNet.ClientCore/Manager/LogManager.cs
+++ b/NoSugarNet.ClientCore/Manager/LogManager.cs
@@ -2,19 +2,30 @@
{
public class LogManager
{
+ ///
+ /// 日志
+ ///
+ ///
+ public delegate void OnLogHandler(int debuglv,string msg);
+
+ ///
+ /// 内部输出
+ ///
+ public static event OnLogHandler OnLog;
+
public void Debug(string str)
{
- Console.WriteLine(str);
+ OnLog?.Invoke(0,str);
}
public void Warning(string str)
{
- Console.WriteLine(str);
+ OnLog?.Invoke(1,str);
}
public void Error(string str)
{
- Console.WriteLine(str);
+ OnLog?.Invoke(2,str);
}
}
}
\ No newline at end of file
diff --git a/NoSugarNet.ClientCore/Network/NetworkHelper.cs b/NoSugarNet.ClientCore/Network/NetworkHelper.cs
index 0814d43..5950979 100644
--- a/NoSugarNet.ClientCore/Network/NetworkHelper.cs
+++ b/NoSugarNet.ClientCore/Network/NetworkHelper.cs
@@ -60,7 +60,7 @@ namespace NoSugarNet.ClientCore.Network
{
//用于Unity内的输出
//Debug.Log("NetCoreDebug >> "+str);
- Console.WriteLine("NetCoreDebug >> " + str);
+ AppNoSugarNet.log.Debug("NetCoreDebug >> " + str);
}
///
diff --git a/NoSugarNet.ClientCore/NoSugarNet.ClientCore.csproj b/NoSugarNet.ClientCore/NoSugarNet.ClientCore.csproj
index 4ef9bb7..2304238 100644
--- a/NoSugarNet.ClientCore/NoSugarNet.ClientCore.csproj
+++ b/NoSugarNet.ClientCore/NoSugarNet.ClientCore.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
-
+
diff --git a/NoSugarNet.sln b/NoSugarNet.sln
index c7bf68b..a77fd95 100644
--- a/NoSugarNet.sln
+++ b/NoSugarNet.sln
@@ -20,7 +20,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoSugarNet.ClientCli", "Sam
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoSugarNet.ServerCli", "Sample\NoSugarNet.ServerCli\NoSugarNet.ServerCli.csproj", "{65220036-9A81-49FA-A5BC-DA06783D2E52}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoSugarNet.DataHelper", "NoSugarNet.DataHelper\NoSugarNet.DataHelper.csproj", "{3C41B685-B46B-4057-826B-C8C6F395BFA8}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoSugarNet.DataHelper", "NoSugarNet.DataHelper\NoSugarNet.DataHelper.csproj", "{3C41B685-B46B-4057-826B-C8C6F395BFA8}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Net4X", "Net4X", "{4A660CAE-CD92-411C-9D8E-7CB677DB3C74}"
+ ProjectSection(SolutionItems) = preProject
+ Lib\Net4x\HaoYueNet.ClientNetworkNet4x.dll = Lib\Net4x\HaoYueNet.ClientNetworkNet4x.dll
+ Lib\Net4x\HaoYueNet.ServerNetworkNet4x.dll = Lib\Net4x\HaoYueNet.ServerNetworkNet4x.dll
+ Lib\Net4x\System.Buffers.dll = Lib\Net4x\System.Buffers.dll
+ Lib\Net4x\System.Memory.dll = Lib\Net4x\System.Memory.dll
+ Lib\Net4x\System.Runtime.CompilerServices.Unsafe.dll = Lib\Net4x\System.Runtime.CompilerServices.Unsafe.dll
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoSugarNet.ClientCoreNet4x", "NoSugarNet.ClientCoreNet4x\NoSugarNet.ClientCoreNet4x.csproj", "{F565C3B8-E210-45F5-9B9E-8C1A49438753}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -48,6 +59,10 @@ Global
{3C41B685-B46B-4057-826B-C8C6F395BFA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C41B685-B46B-4057-826B-C8C6F395BFA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C41B685-B46B-4057-826B-C8C6F395BFA8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F565C3B8-E210-45F5-9B9E-8C1A49438753}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F565C3B8-E210-45F5-9B9E-8C1A49438753}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F565C3B8-E210-45F5-9B9E-8C1A49438753}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F565C3B8-E210-45F5-9B9E-8C1A49438753}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -55,6 +70,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{29D76CF3-BF7E-45A5-9957-2CBC0A41B6FB} = {5E65F25A-8B59-4FC7-8582-C6887C3CD0A1}
{65220036-9A81-49FA-A5BC-DA06783D2E52} = {5E65F25A-8B59-4FC7-8582-C6887C3CD0A1}
+ {4A660CAE-CD92-411C-9D8E-7CB677DB3C74} = {EDA9D3FD-1A72-434D-81F6-B1B420406D20}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {637DC2BB-F9BB-41A2-ADC0-B41B871F66DE}
diff --git a/Sample/NoSugarNet.ClientCli/NoSugarNet.ClientCli.csproj.user b/Sample/NoSugarNet.ClientCli/NoSugarNet.ClientCli.csproj.user
index 6d2fdd4..2241f9c 100644
--- a/Sample/NoSugarNet.ClientCli/NoSugarNet.ClientCli.csproj.user
+++ b/Sample/NoSugarNet.ClientCli/NoSugarNet.ClientCli.csproj.user
@@ -1,6 +1,6 @@
- <_LastSelectedProfileId>F:\Sin365\NoSugarNet\Sample\NoSugarNet.ClientCli\Properties\PublishProfiles\FolderProfile.pubxml
+ <_LastSelectedProfileId>D:\NoSugarNet\Sample\NoSugarNet.ClientCli\Properties\PublishProfiles\FolderProfile.pubxml
\ No newline at end of file
diff --git a/Sample/NoSugarNet.ClientCli/Program.cs b/Sample/NoSugarNet.ClientCli/Program.cs
index 4d48f11..67a5ff9 100644
--- a/Sample/NoSugarNet.ClientCli/Program.cs
+++ b/Sample/NoSugarNet.ClientCli/Program.cs
@@ -14,7 +14,7 @@ namespace NoSugarNet.ClientCli
return;
}
AppNoSugarNet.OnUpdateStatus += OnUpdateStatus;
- AppNoSugarNet.Init(Config.ServerIP, Config.ServerPort);
+ AppNoSugarNet.Init(Config.ServerIP, Config.ServerPort, OnNoSugarNetLog);
while (true)
{
Console.ReadLine();
@@ -31,5 +31,10 @@ namespace NoSugarNet.ClientCli
{
return Math.Round((double)bytes / 1024, 2).ToString("F2");
}
+ static void OnNoSugarNetLog(int LogLevel, string msg)
+ {
+ Console.WriteLine(msg);
+ }
+
}
}
\ No newline at end of file
diff --git a/Sample/NoSugarNet.ClientCli/Properties/PublishProfiles/FolderProfile.pubxml b/Sample/NoSugarNet.ClientCli/Properties/PublishProfiles/FolderProfile.pubxml
index d37ba18..7d6298f 100644
--- a/Sample/NoSugarNet.ClientCli/Properties/PublishProfiles/FolderProfile.pubxml
+++ b/Sample/NoSugarNet.ClientCli/Properties/PublishProfiles/FolderProfile.pubxml
@@ -6,13 +6,12 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
Release
Any CPU
- bin\Release\net8.0\publish\win-x64\
+ bin\Release\net8.0\publish\linux-x64\
FileSystem
<_TargetId>Folder
net8.0
- win-x64
+ linux-x64
false
false
- false
\ No newline at end of file
diff --git a/Sample/NoSugarNet.ClientCli/Properties/PublishProfiles/FolderProfile.pubxml.user b/Sample/NoSugarNet.ClientCli/Properties/PublishProfiles/FolderProfile.pubxml.user
index c2ac5d6..535e1dd 100644
--- a/Sample/NoSugarNet.ClientCli/Properties/PublishProfiles/FolderProfile.pubxml.user
+++ b/Sample/NoSugarNet.ClientCli/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
- True|2024-01-23T08:35:06.3918472Z;True|2024-01-23T16:34:52.0595483+08:00;True|2024-01-23T16:27:36.4850749+08:00;True|2024-01-23T16:27:04.0721589+08:00;
+ True|2024-04-14T14:24:49.2846754Z;True|2024-01-23T16:35:06.3918472+08:00;True|2024-01-23T16:34:52.0595483+08:00;True|2024-01-23T16:27:36.4850749+08:00;True|2024-01-23T16:27:04.0721589+08:00;
\ No newline at end of file