支持.net4x

This commit is contained in:
sin365 2024-04-15 11:30:28 +08:00
parent a86cd5b1f6
commit e3f6029d07
16 changed files with 59 additions and 24 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Lib/Net4x/System.Memory.dll Normal file

Binary file not shown.

Binary file not shown.

View File

@ -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)

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -2,19 +2,30 @@
{
public class LogManager
{
/// <summary>
/// 日志
/// </summary>
/// <param name="sk"></param>
public delegate void OnLogHandler(int debuglv,string msg);
/// <summary>
/// 内部输出
/// </summary>
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);
}
}
}

View File

@ -60,7 +60,7 @@ namespace NoSugarNet.ClientCore.Network
{
//用于Unity内的输出
//Debug.Log("NetCoreDebug >> "+str);
Console.WriteLine("NetCoreDebug >> " + str);
AppNoSugarNet.log.Debug("NetCoreDebug >> " + str);
}
/// <summary>

View File

@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NoSugarNet.DataHelper\NoSugarNet.DataHelper.csproj" />

View File

@ -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}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>F:\Sin365\NoSugarNet\Sample\NoSugarNet.ClientCli\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
<_LastSelectedProfileId>D:\NoSugarNet\Sample\NoSugarNet.ClientCli\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>

View File

@ -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);
}
}
}

View File

@ -6,13 +6,12 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net8.0\publish\win-x64\</PublishDir>
<PublishDir>bin\Release\net8.0\publish\linux-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
</Project>

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>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;</History>
<History>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;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>