Exemplo n.º 1
0
    public virtual async Task EnqueueAsync(IncomingEventInfo incomingEvent)
    {
        var dbContext = await DbContextProvider.GetDbContextAsync();

        dbContext.IncomingEvents.Add(
            new IncomingEventRecord(incomingEvent)
            );
    }
Exemplo n.º 2
0
    public IncomingEventRecord(
        IncomingEventInfo eventInfo)
        : base(eventInfo.Id)
    {
        MessageId    = eventInfo.MessageId;
        EventName    = eventInfo.EventName;
        EventData    = eventInfo.EventData;
        CreationTime = eventInfo.CreationTime;

        ExtraProperties = new ExtraPropertyDictionary();
        this.SetDefaultsForExtraProperties();
    }
Exemplo n.º 3
0
    public virtual async Task EnqueueAsync(IncomingEventInfo incomingEvent)
    {
        var dbContext = await DbContextProvider.GetDbContextAsync();

        if (dbContext.SessionHandle != null)
        {
            await dbContext.IncomingEvents.InsertOneAsync(
                dbContext.SessionHandle,
                new IncomingEventRecord(incomingEvent)
                );
        }
        else
        {
            await dbContext.IncomingEvents.InsertOneAsync(
                new IncomingEventRecord(incomingEvent)
                );
        }
    }
    public async override Task ProcessFromInboxAsync(IncomingEventInfo incomingEvent, InboxConfig inboxConfig)
    {
        var eventType = _eventTypes.GetOrDefault(incomingEvent.EventName);

        if (eventType == null)
        {
            return;
        }

        var eventData  = _serializer.Deserialize(incomingEvent.EventData, eventType);
        var exceptions = new List <Exception>();

        await TriggerHandlersAsync(eventType, eventData, exceptions, inboxConfig);

        if (exceptions.Any())
        {
            ThrowOriginalExceptions(eventType, exceptions);
        }
    }
        public static Task DispatchEvent(
            BrowserEventDescriptor eventDescriptor, string eventArgsJson)
        {
            // Be sure we only run one event handler at once. Although they couldn't run
            // simultaneously anyway (there's only one thread), they could run nested on
            // the stack if somehow one event handler triggers another event synchronously.
            // We need event handlers not to overlap because (a) that's consistent with
            // server-side Blazor which uses a sync context, and (b) the rendering logic
            // relies completely on the idea that within a given scope it's only building
            // or processing one batch at a time.
            //
            // The only currently known case where this makes a difference is in the E2E
            // tests in ReorderingFocusComponent, where we hit what seems like a Chrome bug
            // where mutating the DOM cause an element's "change" to fire while its "input"
            // handler is still running (i.e., nested on the stack) -- this doesn't happen
            // in Firefox. Possibly a future version of Chrome may fix this, but even then,
            // it's conceivable that DOM mutation events could trigger this too.

            if (isDispatchingEvent)
            {
                var info = new IncomingEventInfo(eventDescriptor, eventArgsJson);
                deferredIncomingEvents.Enqueue(info);
                return(info.TaskCompletionSource.Task);
            }
            else
            {
                isDispatchingEvent = true;
                try
                {
                    var eventArgs = ParseEventArgsJson(eventDescriptor.EventArgsType, eventArgsJson);
                    var renderer  = RendererRegistry.Current.Find(eventDescriptor.BrowserRendererId);
                    return(renderer.DispatchEventAsync(eventDescriptor.EventHandlerId, eventArgs));
                }
                finally
                {
                    isDispatchingEvent = false;
                    if (deferredIncomingEvents.Count > 0)
                    {
                        ProcessNextDeferredEvent();
                    }
                }
            }
        }
Exemplo n.º 6
0
 public abstract Task ProcessFromInboxAsync(
     IncomingEventInfo incomingEvent,
     InboxConfig inboxConfig);