Skip to content

Commit

Permalink
net7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
200Tigersbloxed authored Apr 6, 2023
1 parent 4744373 commit d729951
Show file tree
Hide file tree
Showing 36 changed files with 1,523 additions and 1,572 deletions.
13 changes: 6 additions & 7 deletions Nexport.Tests/AuthMessage.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace Nexport.Tests
namespace Nexport.Tests;

[Msg]
public class AuthMessage
{
[Msg]
public class AuthMessage
{
[MsgKey(1)] public string MessageId => typeof(AuthMessage).FullName;
[MsgKey(2)] public string Password;
}
[MsgKey(1)] public string MessageId => typeof(AuthMessage).FullName;
[MsgKey(2)] public string Password;
}
67 changes: 8 additions & 59 deletions Nexport.Tests/Nexport.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,66 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{316D92C7-B598-4753-8C59-A8A8FD17EC8A}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Nexport.Tests</RootNamespace>
<AssemblyName>Nexport.Tests</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net48;net7.0</TargetFrameworks>
<LangVersion>11</LangVersion>
</PropertyGroup>

<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AuthMessage.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Nexport\Nexport.csproj">
<Project>{b86b127e-e474-4ca8-8ee4-4050fd2f97f3}</Project>
<Name>Nexport</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<ProjectReference Include="..\Nexport\Nexport.csproj" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
92 changes: 45 additions & 47 deletions Nexport.Tests/Program.cs
Original file line number Diff line number Diff line change
@@ -1,58 +1,56 @@
using System;
using Nexport.Transports;
using Nexport.Transports;

namespace Nexport.Tests
namespace Nexport.Tests;

internal class Program
{
internal class Program
{
private static Server server;
private static Client client;
private static Server server;
private static Client client;

public static void Main(string[] args)
public static void Main(string[] args)
{
Console.WriteLine("Is this a server? (y/n)");
string inp = Console.ReadLine() ?? "n";
Console.WriteLine("Which Transport? (kcp/telepathy/litenetlib)");
TransportType transportType = Instantiator.GetTransportTypeFromString(Console.ReadLine() ?? "kcp");
if (inp.ToLower().Contains("y"))
{
Console.WriteLine("Is this a server? (y/n)");
string inp = Console.ReadLine() ?? "n";
Console.WriteLine("Which Transport? (kcp/telepathy/litenetlib)");
TransportType transportType = Instantiator.GetTransportTypeFromString(Console.ReadLine() ?? "kcp");
if (inp.ToLower().Contains("y"))
ServerSettings serverSettings = new ServerSettings("0.0.0.0", 3456, useMultithreading: true, requireMessageAuth: true)
{
ServerSettings serverSettings = new ServerSettings("0.0.0.0", 3456, useMultithreading: true, requireMessageAuth: true)
ValidateMessage = (identifier, meta, result) =>
{
ValidateMessage = (identifier, meta, result) =>
{
AuthMessage authMessage = Msg.Deserialize<AuthMessage>(meta.RawData);
result.Invoke(authMessage.Password == "1234");
}
};
server = Instantiator.InstantiateServer(transportType, serverSettings);
server.Create();
server.OnConnect += identifier =>
Console.WriteLine("Client connected with identifier of " + identifier.Identifier);
server.OnDisconnect += identifier =>
Console.WriteLine("Client disconnected with identifier of " + identifier.Identifier);
}
else
AuthMessage authMessage = Msg.Deserialize<AuthMessage>(meta.RawData);
result.Invoke(authMessage.Password == "1234");
}
};
server = Instantiator.InstantiateServer(transportType, serverSettings);
server.Create();
server.OnConnect += identifier =>
Console.WriteLine("Client connected with identifier of " + identifier.Identifier);
server.OnDisconnect += identifier =>
Console.WriteLine("Client disconnected with identifier of " + identifier.Identifier);
}
else
{
Console.WriteLine("What is the Password to Connect?");
string password = Console.ReadLine() ?? "idk";
ClientSettings clientSettings = new ClientSettings("127.0.0.1", 3456, useMultithreading: true);
client = Instantiator.InstantiateClient(transportType, clientSettings);
client.Create();
client.OnConnect += () =>
{
Console.WriteLine("What is the Password to Connect?");
string password = Console.ReadLine() ?? "idk";
ClientSettings clientSettings = new ClientSettings("127.0.0.1", 3456, useMultithreading: true);
client = Instantiator.InstantiateClient(transportType, clientSettings);
client.Create();
client.OnConnect += () =>
Console.WriteLine("Connected to Server!");
client.SendMessage(Msg.Serialize(new AuthMessage
{
Console.WriteLine("Connected to Server!");
client.SendMessage(Msg.Serialize(new AuthMessage
{
Password = password
}));
};
client.JoinedServer += () => Console.WriteLine("Joined Server!");
client.OnNetworkedClientConnect += identifier =>
Console.WriteLine("Client connected with identifier of " + identifier.Identifier);
client.OnNetworkedClientDisconnect += identifier =>
Console.WriteLine("Client disconnected with identifier of " + identifier.Identifier);
client.OnDisconnect += () => Console.WriteLine("Disconnected from Server!");
}
Password = password
}));
};
client.JoinedServer += () => Console.WriteLine("Joined Server!");
client.OnNetworkedClientConnect += identifier =>
Console.WriteLine("Client connected with identifier of " + identifier.Identifier);
client.OnNetworkedClientDisconnect += identifier =>
Console.WriteLine("Client disconnected with identifier of " + identifier.Identifier);
client.OnDisconnect += () => Console.WriteLine("Disconnected from Server!");
}
}
}
20 changes: 10 additions & 10 deletions Nexport.sln
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nexport", "Nexport\Nexport.csproj", "{B86B127E-E474-4CA8-8EE4-4050FD2F97F3}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nexport", "Nexport\Nexport.csproj", "{380EBFA3-3C7F-4920-8DB0-0B669B97C71E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nexport.Tests", "Nexport.Tests\Nexport.Tests.csproj", "{316D92C7-B598-4753-8C59-A8A8FD17EC8A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nexport.Tests", "Nexport.Tests\Nexport.Tests.csproj", "{305AA248-F663-4874-A153-6E88EFB75CD8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B86B127E-E474-4CA8-8EE4-4050FD2F97F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B86B127E-E474-4CA8-8EE4-4050FD2F97F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B86B127E-E474-4CA8-8EE4-4050FD2F97F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B86B127E-E474-4CA8-8EE4-4050FD2F97F3}.Release|Any CPU.Build.0 = Release|Any CPU
{316D92C7-B598-4753-8C59-A8A8FD17EC8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{316D92C7-B598-4753-8C59-A8A8FD17EC8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{316D92C7-B598-4753-8C59-A8A8FD17EC8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{316D92C7-B598-4753-8C59-A8A8FD17EC8A}.Release|Any CPU.Build.0 = Release|Any CPU
{380EBFA3-3C7F-4920-8DB0-0B669B97C71E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{380EBFA3-3C7F-4920-8DB0-0B669B97C71E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{380EBFA3-3C7F-4920-8DB0-0B669B97C71E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{380EBFA3-3C7F-4920-8DB0-0B669B97C71E}.Release|Any CPU.Build.0 = Release|Any CPU
{305AA248-F663-4874-A153-6E88EFB75CD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{305AA248-F663-4874-A153-6E88EFB75CD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{305AA248-F663-4874-A153-6E88EFB75CD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{305AA248-F663-4874-A153-6E88EFB75CD8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
19 changes: 8 additions & 11 deletions Nexport/BuiltinMessages/ServerClientChange.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using System.Collections.Generic;
namespace Nexport.BuiltinMessages;

namespace Nexport.BuiltinMessages
[Msg]
public class ServerClientChange
{
[Msg]
public class ServerClientChange
{
[MsgKey(1)] public string MessageId = typeof(ServerClientChange).FullName;
[MsgKey(2)] public ClientIdentifier[] ConnectedClients;
[MsgKey(3)] public ClientIdentifier LocalClientIdentifier;
[MsgKey(1)] public string MessageId = typeof(ServerClientChange).FullName;
[MsgKey(2)] public ClientIdentifier[] ConnectedClients;
[MsgKey(3)] public ClientIdentifier LocalClientIdentifier;

public ServerClientChange(){}
public ServerClientChange(List<ClientIdentifier> clients) => ConnectedClients = clients.ToArray();
}
public ServerClientChange(){}
public ServerClientChange(List<ClientIdentifier> clients) => ConnectedClients = clients.ToArray();
}
Loading

0 comments on commit d729951

Please sign in to comment.