Exemplo n.º 1
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Starts the asynchronous.
        /// </summary>
        /// <returns>
        ///  A Task.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        protected override Task StartAsync()
        {
            var tcs = new TaskCompletionSource <object>();

            _messages = new Subject <InprocMessage>(EventBus.Store.Services);
            try
            {
                if (EventsProcessor != null)
                {
                    if (HasInputProperty())
                    {
                        // Reception des messages
                        _messages.Subscribe(msg =>
                                            EventsProcessor.ProcessEvents(msg.OriginStoreId, msg.Mode, msg.Events)
                                            );
                    }
                }
                tcs.SetResult(null);
            }
            catch (Exception ex)
            {
                tcs.SetException(ex);
            }
            return(tcs.Task);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Remote call
        ///     Reception des messages distants
        /// </summary>
        /// <param name="data"></param>
        void IWCFHyperstoreChannel.ProcessEvents(Message data)
        {
            DebugContract.Requires(data);

            if (IsDisposed || EventsProcessor == null)
            {
                return;
            }

            var events = new List <IEvent>();

            foreach (var envelope in data.events)
            {
                var @event = envelope.DeserializeEvent();
                if (@event == null)
                {
                    Trace.WriteLine("Ignore event : " + envelope.eventName);
                    continue;
                }

                if (CanReceive(@event))
                {
                    events.Add(@event);
                }
            }

            EventsProcessor.ProcessEvents(data.origin, data.sessionMode, events);
        }