diff --git a/README.md b/README.md index 64b9608..d3ca2a8 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ transports on the default port (`4062`): | Service | Path | Description | Example Clients | | ---------------------------------------------- | --------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [Slice Greeter](./src//slice/Greeter.slice) | `/VisitorCenter.Greeter` | A simple service that greets visitors | [C# Slice Secure](https://github.com/icerpc/icerpc-csharp/tree/0.5.x/examples/slice/Secure/Client)
[C# Slice QUIC](https://github.com/icerpc/icerpc-csharp/tree/0.5.x/examples/slice/Quic/Client) | -| [Protobuf Greeter](./src/proto/greeter.proto) | `/visitor_center.Greeter` | A simple service that greets visitors | [C# Protobuf Secure](https://github.com/icerpc/icerpc-csharp/tree/0.5.x/examples/protobuf/Secure/Client)
[C# Protobuf QUIC](https://github.com/icerpc/icerpc-csharp/tree/0.5.x/examples/protobuf/Quic/Client) | -| [Slice Stream](./src/slice/Generator.slice) | `/StreamExample.Generator` | A service that streams data | [C# Slice Stream](https://github.com/icerpc/icerpc-csharp/tree/0.5.x/examples/slice/Stream/Client) | -| [Protobuf Stream](./src/proto/generator.proto) | `/stream_example.Generator` | A service that streams data | [C# Protobuf Stream](https://github.com/icerpc/icerpc-csharp/tree/0.5.x/examples/protobuf/Stream/Client) | +| [Slice Greeter](./src/slice/Greeter.slice) | `/VisitorCenter.Greeter` | A simple service that greets visitors | [C# Slice Secure](https://github.com/icerpc/icerpc-csharp/tree/0.6.x/examples/slice/Secure/Client)
[C# Slice QUIC](https://github.com/icerpc/icerpc-csharp/tree/0.6.x/examples/slice/Quic/Client) | +| [Protobuf Greeter](./src/proto/greeter.proto) | `/visitor_center.Greeter` | A simple service that greets visitors | [C# Protobuf Secure](https://github.com/icerpc/icerpc-csharp/tree/0.6.x/examples/protobuf/Secure/Client)
[C# Protobuf QUIC](https://github.com/icerpc/icerpc-csharp/tree/0.6.x/examples/protobuf/Quic/Client) | +| [Slice Stream](./src/slice/Generator.slice) | `/StreamExample.Generator` | A service that streams data | [C# Slice Stream](https://github.com/icerpc/icerpc-csharp/tree/0.6.x/examples/slice/Stream/Client) | +| [Protobuf Stream](./src/proto/generator.proto) | `/stream_example.Generator` | A service that streams data | [C# Protobuf Stream](https://github.com/icerpc/icerpc-csharp/tree/0.6.x/examples/protobuf/Stream/Client) | ## Running the server using Docker @@ -40,7 +40,7 @@ docker run \ -e LOG_LEVEL= \ -e SERVER_CERT= \ -e SERVER_KEY= \ - -e USE_TLS_WITH_TCP=true icerpc/hello + icerpc/hello ``` ### Docker Compose @@ -56,7 +56,6 @@ services: - LOG_LEVEL= #optional - SERVER_CERT= #optional - SERVER_KEY= #optional - - USE_TLS_WITH_TCP= #optional volumes: - /path/to/certificates/:/certs @@ -71,7 +70,6 @@ The server can be configured through several environment variables: | `LOG_LEVEL` | The [log level](https://learn.microsoft.com/en-us/dotnet/core/extensions/logging?tabs=command-line#log-level) | `Debug` | | `SERVER_CERT` | Path to the server certificate | `/certs/server_cert.pem` | | `SERVER_KEY` | Path to the server private key | `/certs/server_key.pem` | -| `USE_TLS_WITH_TCP` | Configure the usage of TLS with the TCP transport | `true` | Certificates are **required** to run the server as the QUIC transport requires TLS. diff --git a/src/Hello/Greeter.Protobuf/Chatbot.cs b/src/Hello/Greeter.Protobuf/Chatbot.cs index d8a3f60..063c742 100644 --- a/src/Hello/Greeter.Protobuf/Chatbot.cs +++ b/src/Hello/Greeter.Protobuf/Chatbot.cs @@ -1,12 +1,12 @@ // Copyright (c) ZeroC, Inc. +using IceRpc; using IceRpc.Features; -using IceRpc.Protobuf; namespace Hello.Greeter.Protobuf; /// A Chatbot is an IceRPC service that implements Protobuf service 'Greeter'. -[ProtobufService] +[Service] internal partial class Chatbot : IGreeterService { public ValueTask GreetAsync( diff --git a/src/Hello/Greeter.Slice/Chatbot.cs b/src/Hello/Greeter.Slice/Chatbot.cs index bab4364..4675751 100644 --- a/src/Hello/Greeter.Slice/Chatbot.cs +++ b/src/Hello/Greeter.Slice/Chatbot.cs @@ -1,12 +1,12 @@ // Copyright (c) ZeroC, Inc. +using IceRpc; using IceRpc.Features; -using IceRpc.Slice; namespace Hello.Greeter.Slice; /// A Chatbot is an IceRPC service that implements Slice interface 'Greeter'. -[SliceService] +[Service] internal partial class Chatbot : IGreeterService { public ValueTask GreetAsync(string name, IFeatureCollection features, CancellationToken cancellationToken) diff --git a/src/Hello/Hello.cs b/src/Hello/Hello.cs index e1f2623..c0f88c2 100644 --- a/src/Hello/Hello.cs +++ b/src/Hello/Hello.cs @@ -1,7 +1,6 @@ // Copyright (c) ZeroC, Inc. using IceRpc; -using IceRpc.Transports.Quic; using Microsoft.Extensions.Logging; using System.Net.Security; using System.Security.Cryptography.X509Certificates; @@ -15,9 +14,6 @@ // The server certificate (with the full chain) file. string serverCert = Environment.GetEnvironmentVariable("SERVER_CERT") ?? "/certs/server_cert.pem"; -// Whether to use TLS with the TCP transport. -bool useTlsWithTcp = bool.Parse(Environment.GetEnvironmentVariable("USE_TLS_WITH_TCP") ?? "true"); - // Load server and intermediate certificates from the server certificate file. using var serverCertificate = X509Certificate2.CreateFromPemFile(serverCert, serverKey); @@ -38,29 +34,30 @@ .AddFilter("IceRpc", logLevel)); // Create a router (dispatch pipeline), install two middleware and map the Slice and Protobuf Chatbot greeter services -// to their default paths. +// to their default paths, and the Slice and Protobuf RandomGenerator services to their default paths. Router router = new Router() .UseLogger(loggerFactory) .UseDeadline() - .Map(new Hello.Greeter.Protobuf.Chatbot()) - .Map(new Hello.Greeter.Slice.Chatbot()) - .Map(new Hello.Stream.Protobuf.RandomGenerator()) - .Map(new Hello.Stream.Slice.RandomGenerator()); + .Map(new Hello.Greeter.Protobuf.Chatbot()) + .Map(new Hello.Greeter.Slice.Chatbot()) + .Map(new Hello.Stream.Protobuf.RandomGenerator()) + .Map(new Hello.Stream.Slice.RandomGenerator()); // Create a server that uses the TCP transport on the default port (4062). await using var tcpServer = new Server( router, - useTlsWithTcp ? sslAuthenticationOptions : null, - logger: loggerFactory.CreateLogger()); + serverAddressUri: new Uri("icerpc://[::0]?transport=tcp"), + serverAuthenticationOptions: sslAuthenticationOptions, + logger: loggerFactory.CreateLogger("Hello.TcpServer")); tcpServer.Listen(); // Create a server that uses the QUIC transport on the default port (4062). await using var quicServer = new Server( - router, - sslAuthenticationOptions, - logger: loggerFactory.CreateLogger(), - multiplexedServerTransport: new QuicServerTransport()); + router, + serverAddressUri: new Uri("icerpc://[::0]?transport=quic"), + serverAuthenticationOptions: sslAuthenticationOptions, + logger: loggerFactory.CreateLogger("Hello.QuicServer")); quicServer.Listen(); diff --git a/src/Hello/Hello.csproj b/src/Hello/Hello.csproj index 4979e3c..bd8cca1 100644 --- a/src/Hello/Hello.csproj +++ b/src/Hello/Hello.csproj @@ -15,13 +15,13 @@ True - - - - - - - + + + + + + + @@ -33,8 +33,8 @@ - - + + diff --git a/src/Hello/Stream.Protobuf/RandomGenerator.cs b/src/Hello/Stream.Protobuf/RandomGenerator.cs index 60572ff..db878c3 100644 --- a/src/Hello/Stream.Protobuf/RandomGenerator.cs +++ b/src/Hello/Stream.Protobuf/RandomGenerator.cs @@ -1,14 +1,14 @@ // Copyright (c) ZeroC, Inc. using Google.Protobuf.WellKnownTypes; +using IceRpc; using IceRpc.Features; -using IceRpc.Protobuf; using System.Runtime.CompilerServices; using System.Security.Cryptography; namespace Hello.Stream.Protobuf; -[ProtobufService] +[Service] internal partial class RandomGenerator : IGeneratorService { public ValueTask> GenerateNumbersAsync( diff --git a/src/Hello/Stream.Slice/RandomGenerator.cs b/src/Hello/Stream.Slice/RandomGenerator.cs index c8a72ff..2fd4c4c 100644 --- a/src/Hello/Stream.Slice/RandomGenerator.cs +++ b/src/Hello/Stream.Slice/RandomGenerator.cs @@ -1,13 +1,13 @@ // Copyright (c) ZeroC, Inc. +using IceRpc; using IceRpc.Features; -using IceRpc.Slice; using System.Runtime.CompilerServices; using System.Security.Cryptography; namespace Hello.Stream.Slice; -[SliceService] +[Service] internal partial class RandomGenerator : IGeneratorService { public ValueTask> GenerateNumbersAsync( diff --git a/src/proto/generator.proto b/src/proto/stream_example/generator.proto similarity index 100% rename from src/proto/generator.proto rename to src/proto/stream_example/generator.proto diff --git a/src/proto/greeter.proto b/src/proto/visitor_center/greeter.proto similarity index 100% rename from src/proto/greeter.proto rename to src/proto/visitor_center/greeter.proto diff --git a/src/slice/Generator.slice b/src/slice/StreamExample/Generator.slice similarity index 85% rename from src/slice/Generator.slice rename to src/slice/StreamExample/Generator.slice index 673a238..c6d8f3b 100644 --- a/src/slice/Generator.slice +++ b/src/slice/StreamExample/Generator.slice @@ -1,6 +1,6 @@ // Copyright (c) ZeroC, Inc. -[cs::namespace("Hello.Stream.Slice")] +[cs::identifier("Hello.Stream.Slice")] module StreamExample /// Represents a number generator. diff --git a/src/slice/Greeter.slice b/src/slice/VisitorCenter/Greeter.slice similarity index 87% rename from src/slice/Greeter.slice rename to src/slice/VisitorCenter/Greeter.slice index 6f94e20..159719d 100644 --- a/src/slice/Greeter.slice +++ b/src/slice/VisitorCenter/Greeter.slice @@ -1,6 +1,6 @@ // Copyright (c) ZeroC, Inc. -[cs::namespace("Hello.Greeter.Slice")] +[cs::identifier("Hello.Greeter.Slice")] module VisitorCenter /// Represents a simple greeter.