Exemple #1
0
        public static string Serialize(IKernelEventEnvelope eventEnvelope)
        {
            KernelCommandEnvelope.SerializationModel commandSerializationModel = null;

            if (eventEnvelope.Event.Command is not null && eventEnvelope.Event.Command is not NoCommand)
            {
                var commandEnvelope = KernelCommandEnvelope.Create(eventEnvelope.Event.Command);

                commandSerializationModel = new KernelCommandEnvelope.SerializationModel
                {
                    command     = commandEnvelope.Command,
                    commandType = commandEnvelope.CommandType,
                    token       = eventEnvelope.Event.Command.GetToken()
                };
            }

            var serializationModel = new SerializationModel
            {
                @event    = eventEnvelope.Event,
                eventType = eventEnvelope.EventType,
                command   = commandSerializationModel
            };

            return(JsonSerializer.Serialize(
                       serializationModel,
                       Serializer.JsonSerializerOptions));
        }
        private void DeserializeAndSendEvent(string line)
        {
            IKernelEventEnvelope kernelEventEnvelope = null;

            try
            {
                kernelEventEnvelope = KernelEventEnvelope.Deserialize(line);
            }
            catch (Exception ex)
            {
                var diagnosticEvent = new DiagnosticLogEntryProduced(
                    $"Error while parsing command: {ex.Message}\n{line}", KernelCommand.None);

                _kernelEvents.OnNext(diagnosticEvent);
            }

            if (kernelEventEnvelope is not null)
            {
                _kernelEvents.OnNext(kernelEventEnvelope.Event);
            }
        }
Exemple #3
0
 internal Task HandleKernelEventFromClientAsync(IKernelEventEnvelope envelope) => _backchannelKernelClient.HandleKernelEventFromClientAsync(envelope);
 internal Task HandleKernelEventFromClientAsync(IKernelEventEnvelope envelope)
 {
     _kernelEventsFromClient.OnNext(envelope.Event);
     return(Task.CompletedTask);
 }