public async Task <Kernel> ConnectKernelAsync(KernelInfo kernelInfo) { ProxyKernel?proxyKernel; if (_receiver is not null) { proxyKernel = new ProxyKernel(kernelInfo.LocalName, _receiver.CreateChildReceiver(), _sender); } else { var clientStream = new NamedPipeClientStream( ".", PipeName, PipeDirection.InOut, PipeOptions.Asynchronous, TokenImpersonationLevel.Impersonation); await clientStream.ConnectAsync(); clientStream.ReadMode = PipeTransmissionMode.Message; _receiver = new MultiplexingKernelCommandAndEventReceiver(new KernelCommandAndEventPipeStreamReceiver(clientStream)); _sender = new KernelCommandAndEventPipeStreamSender(clientStream); proxyKernel = new ProxyKernel(kernelInfo.LocalName, _receiver, _sender); } var _ = proxyKernel.StartAsync(); return(proxyKernel);; }
public override Task <Kernel> CreateKernelAsync( KernelConnectionOptions options, KernelInvocationContext context) { Kernel proxyKernel = new ProxyKernel(options.KernelName, _clientSideKernelClient); return(Task.FromResult(proxyKernel)); }
private static ProxyKernel CreateProxyKernel2(NamedPipeConnectionOptions options, NamedPipeClientStream clientStream) { var receiver = new KernelCommandAndEventPipeStreamReceiver(clientStream); var sender = new KernelCommandAndEventPipeStreamSender(clientStream); var proxyKernel = new ProxyKernel(options.KernelName, receiver, sender); var _ = proxyKernel.RunAsync(); return(proxyKernel); }
public override async Task <Kernel> CreateKernelAsync(NamedPipeConnectionOptions options, KernelInvocationContext context) { var clientStream = new NamedPipeClientStream( ".", options.PipeName, PipeDirection.InOut, PipeOptions.Asynchronous, TokenImpersonationLevel.Impersonation); await clientStream.ConnectAsync(); clientStream.ReadMode = PipeTransmissionMode.Message; var client = clientStream.CreateKernelClient(); var proxyKernel = new ProxyKernel(options.KernelName, client); proxyKernel.RegisterForDisposal(client); return(proxyKernel); }
public override async Task <Kernel> CreateKernelAsync( SignalRConnectionOptions options, KernelInvocationContext context) { var connection = new HubConnectionBuilder() .WithUrl(options.HubUrl) .Build(); await connection.StartAsync(); var client = connection.CreateKernelClient(); var proxyKernel = new ProxyKernel(options.KernelName, client); await connection.SendAsync("connect"); proxyKernel.RegisterForDisposal(client); proxyKernel.RegisterForDisposal(async() => { await connection.DisposeAsync(); }); return(proxyKernel); }