Exemple #1
0
        public override async Task <Kernel> CreateKernelAsync(
            SignalRConnectionOptions options,
            KernelInvocationContext context)
        {
            var connection = new HubConnectionBuilder()
                             .WithUrl(options.HubUrl)
                             .Build();

            await connection.StartAsync();

            await connection.SendAsync("connect");

            var receiver    = new KernelCommandAndEventSignalRHubConnectionReceiver(connection);
            var sender      = new KernelCommandAndEventSignalRHubConnectionSender(connection);
            var proxyKernel = new ProxyKernel(options.KernelName, receiver, sender);

            var _ = proxyKernel.RunAsync();

            proxyKernel.RegisterForDisposal(receiver);
            proxyKernel.RegisterForDisposal(async() =>
            {
                await connection.DisposeAsync();
            });

            return(proxyKernel);
        }
Exemple #2
0
        public async Task <Kernel> ConnectKernelAsync(KernelInfo kernelInfo)
        {
            // QUESTION: (ConnectKernelAsync) tests?
            var hubConnection = new HubConnectionBuilder()
                                .WithUrl(HubUrl)
                                .Build();

            await hubConnection.StartAsync();

            await hubConnection.SendAsync("connect");

            var receiver    = new KernelCommandAndEventSignalRHubConnectionReceiver(hubConnection);
            var sender      = new KernelCommandAndEventSignalRHubConnectionSender(hubConnection);
            var proxyKernel = new ProxyKernel(kernelInfo.LocalName, receiver, sender);

            var _ = proxyKernel.StartAsync();

            proxyKernel.RegisterForDisposal(receiver);
            proxyKernel.RegisterForDisposal(async() =>
            {
                await hubConnection.DisposeAsync();
            });

            return(proxyKernel);
        }