Beispiel #1
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);
        }
Beispiel #2
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);
        }