Using static NamedPipeClient? PipeClient { get; set; } in Vector3DebuggerVisualizerProvider works.
new VisualizerTargetType("Frame Array Visualizer", "Num.Roto.Visualization.Math.Geometry.Frame[]
This commit is contained in:
@@ -7,6 +7,11 @@ using PipeMethodCalls;
|
||||
namespace NamedPipes;
|
||||
public partial class NamedPipesServer(string pipeName,Action<string>? logger = null) : ObservableObject,IDebugVisualizer, IDisposable
|
||||
{
|
||||
~NamedPipesServer()
|
||||
{
|
||||
Logger(@"~NamedPipesServer called!");
|
||||
|
||||
}
|
||||
public bool IsConnected => PipeServer is { State: PipeState.Connected };
|
||||
private PipeServer<IDebugVisualizer>? PipeServer {get; set;}
|
||||
private string PipeName { get; } = pipeName;
|
||||
@@ -15,15 +20,28 @@ public partial class NamedPipesServer(string pipeName,Action<string>? logger = n
|
||||
public async Task WaitForConnectionAsync()
|
||||
{
|
||||
if(IsConnected) return;
|
||||
if (PipeServer == null || PipeServer.State == PipeState.Closed)
|
||||
if (PipeServer == null || PipeServer.State != PipeState.Connected)
|
||||
{
|
||||
PipeServer?.Dispose();
|
||||
PipeServer = new PipeServer<IDebugVisualizer>(new PipeSerializer(), PipeName, () => this);
|
||||
PipeServer.SetLogger((m) => Trace.WriteLine(m));
|
||||
}
|
||||
await PipeServer.WaitForConnectionAsync();
|
||||
}
|
||||
Logger("Waiting for client connection...");
|
||||
await PipeServer.WaitForConnectionAsync().ConfigureAwait(true);
|
||||
}
|
||||
public async Task RunAsync()
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
await WaitForConnectionAsync().ConfigureAwait(true);
|
||||
Logger("Client connected.");
|
||||
while (IsConnected)
|
||||
{
|
||||
await Task.Delay(100).ConfigureAwait(true);
|
||||
}
|
||||
Logger("Client disconnected.");
|
||||
}
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
public partial DebugObject? DebugObject { get; private set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user