Example #1
0
        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);;
        }
Example #2
0
        public override Task <Kernel> CreateKernelAsync(
            KernelConnectionOptions options,
            KernelInvocationContext context)
        {
            Kernel proxyKernel = new ProxyKernel(options.KernelName, _clientSideKernelClient);

            return(Task.FromResult(proxyKernel));
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }