public void Init()
        {
            foreach (IClientEvent eventToHandle in this.options.EventsToHandle)
            {
                this.logger.LogDebug("Create subscription for {0}", eventToHandle.NodeEventType);

                async Task callback(EventBase eventBase)
                {
                    Type childType = eventBase.GetType();

                    IClientEvent clientEvent = this.options.EventsToHandle.FirstOrDefault(ev => ev.NodeEventType == childType);

                    if (clientEvent == null)
                    {
                        return;
                    }

                    clientEvent.BuildFrom(eventBase);

                    await this.eventsHub.SendToClientsAsync(clientEvent).ConfigureAwait(false);
                }

                this.signals.Subscribe(eventToHandle.NodeEventType, callback);
            }
        }
Example #2
0
        // ReSharper disable once UnusedMember.Global
        // This is invoked through reflection
        public void OnEvent(EventBase @event)
        {
            Type         childType   = @event.GetType();
            IClientEvent clientEvent = this.options.EventsToHandle.FirstOrDefault(ev => ev.NodeEventType == childType);

            if (clientEvent == null)
            {
                return;
            }
            clientEvent.BuildFrom(@event);
            this.eventsHub.SendToClients(clientEvent).ConfigureAwait(false).GetAwaiter().GetResult();
        }