2026-11-10 10:55:06 +01:00
|
|
|
using PipeShared;
|
2026-11-10 09:23:35 +01:00
|
|
|
using PipeMethodCalls;
|
|
|
|
|
using Server;
|
|
|
|
|
|
2026-11-10 09:31:18 +01:00
|
|
|
string pipeName = args.FirstOrDefault(static a => a.StartsWith(PipeConstants.PipeNameArgPrefix, StringComparison.Ordinal))?
|
2026-11-10 09:23:35 +01:00
|
|
|
[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).
|
2026-11-10 11:08:33 +01:00
|
|
|
var server = new PipeServer<IPipeServerMethods>(
|
2026-11-10 09:23:35 +01:00
|
|
|
new JsonFieldsPipeSerializer(),
|
|
|
|
|
pipeName,
|
2026-11-10 10:42:57 +01:00
|
|
|
() => new ServerMethods());
|
2026-11-10 09:23:35 +01:00
|
|
|
|
|
|
|
|
await server.WaitForConnectionAsync();
|
|
|
|
|
Console.WriteLine("Client connected.");
|
|
|
|
|
|
|
|
|
|
await server.WaitForRemotePipeCloseAsync();
|
|
|
|
|
Console.WriteLine("Client disconnected. Server exiting.");
|