Files
PipeMethodCallsDemo/Server/Program.cs
T
Matthias Heil 06763d6c15 Rename shared namespace and preserve pipe handling
Rename `Shared` to `ClientServerShared` across client, server, calculator, interface, and serializer code. Update pipe-name parsing to use ordinal comparison while retaining the `PipeDemo` default. Preserve custom JSON serialization with public field support for `Vector3`.
2026-11-10 09:31:18 +01:00

22 lines
780 B
C#

using ClientServerShared;
using PipeMethodCalls;
using Server;
string pipeName = args.FirstOrDefault(static a => a.StartsWith(PipeConstants.PipeNameArgPrefix, StringComparison.Ordinal))?
[PipeConstants.PipeNameArgPrefix.Length..] ?? "PipeDemo";
Console.WriteLine($"Server started. Pipe: {pipeName}");
// Exceptions in handler methods are caught by PipeMethodCalls and sent to the client
// (client receives PipeInvokeFailedException with the server exception details).
var server = new PipeServer<ICalculator>(
new JsonFieldsPipeSerializer(),
pipeName,
() => new Calculator());
await server.WaitForConnectionAsync();
Console.WriteLine("Client connected.");
await server.WaitForRemotePipeCloseAsync();
Console.WriteLine("Client disconnected. Server exiting.");