public async Task SendAsync(KernelCommand command, string token = null) { if (!string.IsNullOrWhiteSpace(token)) { command.SetToken(token); } var completionSource = new TaskCompletionSource <bool>(); token = command.GetToken(); var sub = _kernelEvents .Where(e => e.Command.GetToken() == token) .Subscribe(kernelEvent => { switch (kernelEvent) { case CommandFailed _: case CommandSucceeded _: completionSource.SetResult(true); break; } }); var envelope = KernelCommandEnvelope.Create(command); var serialized = KernelCommandEnvelope.Serialize(envelope); _output.Write(serialized); await completionSource.Task; sub.Dispose(); }
private void Write(IKernelEvent e, int id) { var wrapper = new StreamKernelEvent { Id = id, Event = e, EventType = e.GetType().Name }; var serialized = wrapper.Serialize(); _output.Write(serialized); }
private void WriteEventToOutput(KernelEvent kernelEvent) { if (kernelEvent is ReturnValueProduced rvp && rvp.Value is DisplayedValue) { return; } var envelope = KernelEventEnvelope.Create(kernelEvent); var serialized = KernelEventEnvelope.Serialize(envelope); _output.Write(serialized); }
private void Write(IKernelEvent kernelEvent, int correlationId) { if (kernelEvent is ReturnValueProduced rvp && rvp.Value is DisplayedValue) { return; } var wrapper = new StreamKernelEvent { Id = correlationId, Event = kernelEvent, EventType = kernelEvent.GetType().Name }; var serialized = wrapper.Serialize(); _output.Write(serialized); }