Files
PipeMethodCallsDemo/PipeServer/Program.cs
T
Matthias Heil ae723b9bea Align client and solution with renamed projects
Update project references and solution entries to use
`PipeClient` and `PipeServer`, and launch the renamed
`PipeServer.exe` or `PipeServer.dll`.
2026-11-10 10:57:10 +01:00

22 lines
778 B
C#

using PipeShared;
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<IServerMethods>(
new JsonFieldsPipeSerializer(),
pipeName,
() => new ServerMethods());
await server.WaitForConnectionAsync();
Console.WriteLine("Client connected.");
await server.WaitForRemotePipeCloseAsync();
Console.WriteLine("Client disconnected. Server exiting.");