JSSoft.Communication
2.0.5-pr.34
See the version list below for details.
dotnet add package JSSoft.Communication --version 2.0.5-pr.34
NuGet\Install-Package JSSoft.Communication -Version 2.0.5-pr.34
<PackageReference Include="JSSoft.Communication" Version="2.0.5-pr.34" />
paket add JSSoft.Communication --version 2.0.5-pr.34
#r "nuget: JSSoft.Communication, 2.0.5-pr.34"
// Install JSSoft.Communication as a Cake Addin #addin nuget:?package=JSSoft.Communication&version=2.0.5-pr.34&prerelease // Install JSSoft.Communication as a Cake Tool #tool nuget:?package=JSSoft.Communication&version=2.0.5-pr.34&prerelease
Communication
Summary
The Communication library is network module using https://github.com/grpc/grpc.
Development Environment
.NET 8.0
c# 12.0
Clone
git clone https://github.com/s2quake/communication.git
cd communication
Build
dotnet build
Run server
dotnet run --project src/JSSoft.Communication.Server
Run client
dotnet run --project src/JSSoft.Communication.Client
Quick start
1. Create solution
Run terminal and execute the command line below to create a solution and project
mkdir .example
dotnet new sln -o .example
dotnet new console -o .example/Server-Test
dotnet new console -o .example/Client-Test
dotnet sln .example add .example/Server-Test
dotnet sln .example add .example/Client-Test
dotnet add .example/Server-Test reference src/JSSoft.Communication
dotnet add .example/Client-Test reference src/JSSoft.Communication
2. Define service
Create IMyService.cs
file in the path .example/Server-Test.
Then copy and paste the code below into the file IMyService.cs
.
namespace Services;
public interface IMyService
{
Task<Guid> LoginAsync(string userID, CancellationToken cancellationToken);
Task<(string product, string version)> GetVersionAsync(CancellationToken cancellationToken);
}
3. Implement service
Create MyService.cs
file in the path .example/Server-Test.
Then copy and paste the code below into the file MyService.cs
.
using JSSoft.Communication;
namespace Services;
sealed class MyService : ServerService<IMyService>, IMyService
{
public Task<Guid> LoginAsync(string userID, CancellationToken cancellationToken)
{
return Task.Run(() =>
{
Console.WriteLine($"logged in: '{userID}'");
return Guid.NewGuid();
}, cancellationToken);
}
public Task<(string product, string version)> GetVersionAsync(CancellationToken cancellationToken)
{
return Task.Run(() =>
{
return ("MyServer", "1.0.0.0");
}, cancellationToken);
}
}
4. Implement code to run the server
Create Program.cs
file in the path .example/Server-Test.
Then copy and paste the code below into the file Program.cs
.
using JSSoft.Communication;
using JSSoft.Communication.Extensions;
using Services;
var service = new MyService();
var serviceContext = new ServerContext([service]);
var token = await serviceContext.OpenAsync(cancellationToken: default);
Console.WriteLine("Server has been started.");
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
var exitCode = await serviceContext.ReleaseAsync(token);
Environment.Exit(exitCode);
5. Implement code to run the client
First, you need to include the file IMyService.cs
that you created when you created the Server-Test project.
Open .example/Client-Test/Client-Test.csproj
and insert <Compile Include="..\Server-Test\IMyService.cs" />
into the file as shown below.
...
<ItemGroup>
<ProjectReference Include="..\..\src\JSSoft.Communication\JSSoft.Communication.csproj" />
<Compile Include="..\Server-Test\IMyService.cs" />
</ItemGroup>
...
And create Program.cs
file in the path .example/Server-Test.
Then copy and paste the code below into the file Program.cs
.
using JSSoft.Communication;
using JSSoft.Communication.Extensions;
using Services;
var service = new ClientService<IMyService>();
var serviceContext = new ClientContext([service]);
var token = await serviceContext.OpenAsync(cancellationToken: default);
var server = service.Server;
var id = await server.LoginAsync("admin", cancellationToken: default);
var (product, version) = await server.GetVersionAsync(cancellationToken: default);
Console.WriteLine($"logged in: {id}");
Console.WriteLine($"product: {product}");
Console.WriteLine($"version: {version}");
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
var exitCode = await serviceContext.ReleaseAsync(token);
Environment.Exit(exitCode);
6. Build and Run example
Build example solution
dotnet build .example
Run Server-Test example project in terminal
dotnet run --project .example/Server-Test
Run Client-Test example project in a new terminal
dotnet run --project .example/Client-Test
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Google.Protobuf (>= 3.25.1)
- Grpc.Core (>= 2.46.6)
- System.Text.Json (>= 8.0.3)
-
net6.0
- Google.Protobuf (>= 3.25.1)
- Grpc.AspNetCore (>= 2.63.0)
- Grpc.AspNetCore.Server (>= 2.63.0)
- Grpc.Net.Client (>= 2.63.0)
- System.Text.Json (>= 8.0.3)
-
net7.0
- Google.Protobuf (>= 3.25.1)
- Grpc.AspNetCore (>= 2.63.0)
- Grpc.AspNetCore.Server (>= 2.63.0)
- Grpc.Net.Client (>= 2.63.0)
- System.Text.Json (>= 8.0.3)
-
net8.0
- Google.Protobuf (>= 3.25.1)
- Grpc.AspNetCore (>= 2.63.0)
- Grpc.AspNetCore.Server (>= 2.63.0)
- Grpc.Net.Client (>= 2.63.0)
- System.Text.Json (>= 8.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.6 | 275 | 6/30/2024 |
2.0.6-pr.35 | 50 | 6/30/2024 |
2.0.6-pr.34 | 55 | 6/30/2024 |
2.0.5 | 98 | 6/30/2024 |
2.0.5-pr.34 | 45 | 6/30/2024 |
2.0.3-pr.33 | 50 | 6/30/2024 |
2.0.3-pr.32 | 47 | 6/30/2024 |
2.0.3-pr.31 | 43 | 6/30/2024 |
2.0.3-pr.30 | 53 | 6/30/2024 |
2.0.3-pr.29 | 54 | 6/29/2024 |
2.0.3-pr.28 | 50 | 6/29/2024 |
2.0.3-pr.27 | 48 | 6/29/2024 |
2.0.3-pr.26 | 50 | 6/29/2024 |
2.0.2 | 112 | 6/16/2024 |
2.0.1 | 114 | 6/4/2024 |
2.0.0 | 105 | 6/1/2024 |