예제 #1
0
        public void ScheduleTimeoutAction(string token, Delegate callback)
        {
            var ctx = MessagelessContext.CurrentContext;

            if (ctx == null)
            {
                return;
            }
            if (ctx.TimeOut == default(TimeSpan))
            {
                return;
            }
            var subscription = Observable
                               .Timer(ctx.TimeOut)
                               .Select(_ =>
            {
                var context = new Context {
                    RecipientKey = token, TimeOut = ctx.TimeOut, CallbackTimedOut = true
                };
                var callbackMessage = new CallbackMessage(context, callback.GetType(), null);

                var payload          = m_serializer.Serialize(callbackMessage);
                var transportMessage = new TransportMessage(payload, m_transport.LocalPath);
                return(transportMessage);
            })
                               .Finally(() => DismissTimeoutAction(token))
                               .Subscribe(m_transport);

            m_timeoutTimers[token] = subscription;
        }
예제 #2
0
        private void intercept(params object[] args)
        {
            var msg = new CallbackMessage(m_context, m_delegateType, args);

            replaceCallbacksWithTokens(msg);
            var payload          = m_serializer.Serialize(msg);
            var transportMessage = new TransportMessage(payload, m_context.RecipientPath);

            m_transport.OnNext(transportMessage);
        }
예제 #3
0
        public void Handle(CallbackMessage msg)
        {
            var token = msg.Context.RecipientKey;
            m_timeoutManager.DismissTimeoutAction(token);

            Delegate callback;
            lock (m_locker)
            {
                if (!m_kernel.HasComponent(token))
                    return;

                callback = m_kernel.Resolve<Delegate>(token);
                m_kernel.RemoveComponent(token);
            }

            Console.WriteLine("resolved and removed " + token);
            replaceTokensWithCallbackProxies(msg, msg.Context.SenderPath);
            MessagelessContext.Execute(context => callback.DynamicInvoke(msg.Arguments), msg.Context);
        }
예제 #4
0
        public void ScheduleTimeoutAction(string token, Delegate callback)
        {
            var ctx = MessagelessContext.CurrentContext;
            if (ctx == null)
                return;
            if (ctx.TimeOut == default(TimeSpan))
                return;
            var subscription = Observable
                .Timer(ctx.TimeOut)
                .Select(_ =>
                {
                    var context = new Context { RecipientKey = token, TimeOut = ctx.TimeOut, CallbackTimedOut = true };
                    var callbackMessage = new CallbackMessage(context, callback.GetType(), null);

                    var payload = m_serializer.Serialize(callbackMessage);
                    var transportMessage = new TransportMessage(payload, m_transport.LocalPath);
                    return transportMessage;
                })
                .Finally(() => DismissTimeoutAction(token))
                .Subscribe(m_transport);

            m_timeoutTimers[token] = subscription;
        }
예제 #5
0
        public void Handle(CallbackMessage msg)
        {
            var token = msg.Context.RecipientKey;

            m_timeoutManager.DismissTimeoutAction(token);

            Delegate callback;

            lock (m_locker)
            {
                if (!m_kernel.HasComponent(token))
                {
                    return;
                }

                callback = m_kernel.Resolve <Delegate>(token);
                m_kernel.RemoveComponent(token);
            }

            Console.WriteLine("resolved and removed " + token);
            replaceTokensWithCallbackProxies(msg, msg.Context.SenderPath);
            MessagelessContext.Execute(context => callback.DynamicInvoke(msg.Arguments), msg.Context);
        }