internal async Task TriggerEventAsync <T>(IOutgoingEvent <T> e) { var json = JsonConvert.SerializeObject(e); _logger.Debug("Sending event {0} to {1}: {2}", e.EventName, e.Channel ?? "all channels", json); await _connection.SendMessage(json); }
public EventObject(IOutgoingEvent outgoingEvent) { if (outgoingEvent is null) { throw new ArgumentNullException(nameof(outgoingEvent)); } SendId = outgoingEvent.SendId; NameParts = outgoingEvent.NameParts; Data = outgoingEvent.Data; }
public HostEvent(IIoProcessor ioProcessor, ServiceId senderServiceId, ServiceId?targetServiceId, IOutgoingEvent outgoingEvent) : base(outgoingEvent) { if (outgoingEvent is null) { throw new ArgumentNullException(nameof(outgoingEvent)); } _ioProcessor = ioProcessor ?? throw new ArgumentNullException(nameof(ioProcessor)); SenderServiceId = senderServiceId ?? throw new ArgumentNullException(nameof(senderServiceId)); TargetServiceId = targetServiceId; Type = EventType.External; DelayMs = outgoingEvent.DelayMs; InvokeId = senderServiceId as InvokeId; OriginType = ioProcessor.Id; }
async ValueTask <SendStatus> IExternalCommunication.TrySendEvent(IOutgoingEvent outgoingEvent, CancellationToken token) { if (outgoingEvent is null) { throw new ArgumentNullException(nameof(outgoingEvent)); } try { if (_options.ExternalCommunication is not { } externalCommunication) { throw NoExternalCommunication(); } return(await externalCommunication.TrySendEvent(outgoingEvent, token).ConfigureAwait(false)); } catch (Exception ex) { throw new CommunicationException(ex, _sessionId, outgoingEvent.SendId); } }
public async ValueTask SendToCreator(IOutgoingEvent outgoingEvent, CancellationToken token) { if (outgoingEvent.Type is not null || outgoingEvent.SendId is not null || outgoingEvent.DelayMs != 0) { throw new ProcessorException(Resources.Exception_TypeSendIdDelayMsCantBeSpecifiedForThisEvent); } if (outgoingEvent.Target != EventEntity.ParentTarget && outgoingEvent.Target is not null) { throw new ProcessorException(Resources.Exception_TargetShouldBeEqualToParentOrNull); } var newOutgoingEvent = new EventEntity { NameParts = outgoingEvent.NameParts, Data = outgoingEvent.Data, Type = _type, Target = _target }; await _host.DispatchEvent(_invokeId, newOutgoingEvent, token).ConfigureAwait(false); }
public EventNode(IOutgoingEvent outgoingEvent) => _outgoingEvent = outgoingEvent;
public void SetEvent(IOutgoingEvent outgoingEvent) => _outgoingEvent = outgoingEvent ?? throw new ArgumentNullException(nameof(outgoingEvent));