Flynk.Net.Services.Transmit.Grpc.Client
1.5.0
Prefix Reserved
dotnet add package Flynk.Net.Services.Transmit.Grpc.Client --version 1.5.0
NuGet\Install-Package Flynk.Net.Services.Transmit.Grpc.Client -Version 1.5.0
<PackageReference Include="Flynk.Net.Services.Transmit.Grpc.Client" Version="1.5.0" />
<PackageVersion Include="Flynk.Net.Services.Transmit.Grpc.Client" Version="1.5.0" />
<PackageReference Include="Flynk.Net.Services.Transmit.Grpc.Client" />
paket add Flynk.Net.Services.Transmit.Grpc.Client --version 1.5.0
#r "nuget: Flynk.Net.Services.Transmit.Grpc.Client, 1.5.0"
#:package Flynk.Net.Services.Transmit.Grpc.Client@1.5.0
#addin nuget:?package=Flynk.Net.Services.Transmit.Grpc.Client&version=1.5.0
#tool nuget:?package=Flynk.Net.Services.Transmit.Grpc.Client&version=1.5.0
Flynk.Net.Services.Transmit.Grpc.Client
Lightweight gRPC client library for the Flynk Transmission Service. Provides typed RPC communication with routing, serialization, and reconnection support.
Features
- Typed request/response handling with automatic JSON serialization
- Route-based message handlers
- Built-in reconnection with configurable settings
- Service discovery via Info endpoint
- Echo endpoint for connectivity testing
- No ASP.NET Core dependencies - ideal for mobile, desktop, and microservice clients
Installation
dotnet add package Flynk.Net.Services.Transmit.Grpc.Client
Quick Start
using Flynk.Net.Services.Transmit.Grpc.Client;
using Microsoft.Extensions.Logging;
// Create logger
var loggerFactory = LoggerFactory.Create(b => b.AddConsole());
var logger = loggerFactory.CreateLogger<RpcClient>();
// Create client
using var client = new RpcClient(
address: "http://localhost:5001",
id: "my-client",
logger: logger,
loggerFactory: loggerFactory // Recommended: enables TransmissionClient logging
);
// Send request to server (no recipientId = routes to server)
var response = await client.RequestAsync<PingRequest, PingResponse>(
route: "ping",
request: new PingRequest { Message = "Hello!" },
timeout: TimeSpan.FromSeconds(10) // Optional timeout (default: 30s)
);
if (response.IsOK)
{
Console.WriteLine($"Server replied: {response.Payload.Message}");
}
Receiving Messages
Register handlers to receive and process incoming requests:
// Register a typed handler
client.RegisterRoute<OrderRequest, OrderResponse>("order.create",
async (request) =>
{
var order = ProcessOrder(request);
return Response<OrderResponse>.OK(order);
});
// Start listening for incoming messages
client.StartListening();
// Keep running...
Console.ReadLine();
// Cleanup
await client.StopListeningAsync();
Configuration
var settings = new RpcClientSettings
{
EnableReconnection = true, // Auto-reconnect on disconnect
ReconnectionDelaySeconds = 5, // Wait between attempts
MaxReconnectionAttempts = 10 // Use -1 for unlimited
};
var client = new RpcClient(
address: "http://localhost:5001",
id: "my-client",
logger: logger,
settings: settings,
loggerFactory: loggerFactory // Optional: enables TransmissionClient logging
);
Logger Factory
Pass ILoggerFactory to enable logging within the internal TransmissionClient. Without it, connection errors, streaming diagnostics, and reconnection attempts from the transport layer are silently discarded.
// Recommended: pass the same loggerFactory used for the RpcClient logger
var client = new RpcClient(
address: "http://localhost:5001",
id: "my-client",
logger: loggerFactory.CreateLogger<RpcClient>(),
loggerFactory: loggerFactory
);
Custom JSON Serialization
var jsonOptions = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var client = new RpcClient(
address: "http://localhost:5001",
id: "my-client",
logger: logger,
jsonOptions: jsonOptions
);
Built-in System Routes
// Get information about another client
var info = await client.Info("target-client-id");
// Returns: ClientId, MachineName, OSVersion, ProcessId, CLRVersion, RegisteredRoutes
// Test connectivity with echo (generic - works with any type)
var echo = await client.Echo("test message", "target-client-id");
var echoInt = await client.Echo(42, "target-client-id");
var echoObject = await client.Echo(new MyData { Value = "test" }, "target-client-id");
Response Handling
// Success responses
return Response<MyResponse>.OK(payload);
return Response<MyResponse>.OK(payload, "Optional message");
// Failure responses
return Response<MyResponse>.FAILED("Error description");
Timeout Handling
Requests support configurable timeouts (default: 30 seconds):
// Request with custom timeout
var response = await client.RequestAsync<MyRequest, MyResponse>(
route: "my.route",
request: new MyRequest(),
recipientId: "target",
timeout: TimeSpan.FromSeconds(5)
);
// Check for timeout
if (!response.IsOK && response.Message.Contains("timed out"))
{
Console.WriteLine("Request timed out!");
}
Class-Based Handlers
public class OrderHandler : TypedRouteHandler<OrderRequest, OrderResponse>
{
protected override async Task<Response<OrderResponse>> HandleTypedAsync(
OrderRequest request,
Dictionary<string, string> metadata)
{
var order = await ProcessOrder(request);
return Response<OrderResponse>.OK(order);
}
}
// Register
client.RegisterHandler("order.create", new OrderHandler());
Server Package
For hosting the gRPC server, install the companion package:
dotnet add package Flynk.Net.Services.Transmit.Grpc.Server
See the Server package documentation for setup instructions.
License
This software is licensed under the Flynk Freeware License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Flynk.Common.Utils (>= 6.2.2)
- Flynk.Net.Services.Transmit.Grpc.Common (>= 1.5.0)
- Google.Protobuf (>= 3.32.1)
- Grpc.Net.Client (>= 2.71.0)
- Microsoft.Extensions.Logging (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- MongoDB.Bson (>= 3.5.0)
- System.Text.Json (>= 8.0.5)
- System.Threading.Channels (>= 8.0.0)
-
net9.0
- Flynk.Common.Utils (>= 6.2.2)
- Flynk.Net.Services.Transmit.Grpc.Common (>= 1.5.0)
- Google.Protobuf (>= 3.32.1)
- Grpc.Net.Client (>= 2.71.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- MongoDB.Bson (>= 3.5.0)
- System.Text.Json (>= 9.0.0)
- System.Threading.Channels (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.