Beispiel #1
0
        /// <summary>
        /// Performs a function invocation on the desired target method
        /// </summary>
        /// <param name="source">The source of the message</param>
        /// <param name="message">The message object</param>
        /// <returns>True if the method exists, false otherwise</returns>
        public static bool Invoke(IMessageSource source, IMessage message)
        {
            string invocationTarget; if (message.TryGetInvocationTarget(out invocationTarget))

            {
                registryLock.ReadLock();
                try
                {
                    Action <IMessageSource, IMessage> target; if (registry.TryGetValue(invocationTarget, out target))
                    {
                        target(source, message);
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                finally
                {
                    registryLock.ReadRelease();
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 public bool Dispatch(ref IMessage message)
 {
     subscriptionLock.ReadLock();
     try
     {
         foreach (IPrioritizedActor actor in subscriptions)
         {
             try
             {
                 if (actor.OnNext(message))
                 {
                     return(true);
                 }
             }
             catch (Exception er)
             {
                 try
                 {
                     actor.OnError(er);
                 }
                 catch { }
             }
         }
     }
     finally
     {
         subscriptionLock.ReadRelease();
     }
     return(false);
 }
Beispiel #3
0
 public override bool TryGet(ref IMessage message, out IReactiveStream <IMessage, bool> result)
 {
     streamLock.ReadLock();
     try
     {
         return(streams.TryGetValue(message.Id, out result));
     }
     finally
     {
         streamLock.ReadRelease();
     }
 }