![]() |
VOOZH | about |
dotnet add package IceRpc.Protobuf --version 0.6.0
NuGet\Install-Package IceRpc.Protobuf -Version 0.6.0
<PackageReference Include="IceRpc.Protobuf" Version="0.6.0" />
<PackageVersion Include="IceRpc.Protobuf" Version="0.6.0" />Directory.Packages.props
<PackageReference Include="IceRpc.Protobuf" />Project file
paket add IceRpc.Protobuf --version 0.6.0
#r "nuget: IceRpc.Protobuf, 0.6.0"
#:package IceRpc.Protobuf@0.6.0
#addin nuget:?package=IceRpc.Protobuf&version=0.6.0Install as a Cake Addin
#tool nuget:?package=IceRpc.Protobuf&version=0.6.0Install as a Cake Tool
The IceRPC framework allows you to make RPCs with the serialization format and IDL of your choice. It provides full support for both Slice and Protobuf.
IceRpc.Protobuf provides integration code between the IceRPC core APIs and code generated by IceRPC's protoc plug-in for C#.
Package | Source code | Documentation | Examples | API reference
// Protobuf contract
syntax = "proto3";
package visitor_center;
option csharp_namespace = "VisitorCenter";
// Represents a simple greeter.
service Greeter {
rpc Greet (GreetRequest) returns (GreetResponse);
}
message GreetRequest {
string name = 1;
}
message GreetResponse {
string greeting = 1;
}
// Client application
using IceRpc;
using VisitorCenter;
await using var connection = new ClientConnection(new Uri("icerpc://localhost"));
// GreeterClient is a struct generated by protoc-gen-icerpc-csharp.
var greeter = new GreeterClient(connection);
var request = new GreetRequest { Name = Environment.UserName };
GreetResponse response = await greeter.GreetAsync(request);
Console.WriteLine(response.Greeting);
await connection.ShutdownAsync();
// Server application
using IceRpc;
using VisitorCenter;
// Create a server that dispatches all requests to the same service, an instance of
// Chatbot.
await using var server = new Server(new Chatbot());
server.Listen();
// Wait until the console receives a Ctrl+C.
await CancelKeyPressed;
await server.ShutdownAsync();
// IGreeterService is an interface generated by protoc-gen-icerpc-csharp.
// The [Service] attribute instructs the Service source generator to implement IDispatcher
// by routing "Greet" requests to the GreetAsync method.
[Service]
internal partial class Chatbot : IGreeterService
{
public ValueTask<GreetResponse> GreetAsync(
GreetRequest message,
IFeatureCollection features,
CancellationToken cancellationToken)
{
Console.WriteLine($"Dispatching Greet request {{ name = '{message.Name}' }}");
return new(new GreetResponse { Greeting = $"Hello, {message.Name}!" });
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.