Example #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);
        }