Esempio n. 1
0
        private Task OnMessage(RabbitDelegateMessage rabbitDelegateMessage)
        {
            // Uses reflection to get the requested method from the provided client class and invokes it.
            MethodInfo methodInfo = _clientType.GetMethod(rabbitDelegateMessage.Method);

            return(Task.Factory.StartNew(() => methodInfo.Invoke(_client, rabbitDelegateMessage.Args)));
        }
 private object CallClients(RabbitDelegateMessage message)
 {
     if (Bus.IsConnected)
     {
         Bus.Publish(message, _topic);
     }
     else
     {
         throw new NotConnectedException();
     }
     return(null);
 }
        private RabbitResponseMessage Responder(RabbitDelegateMessage rabbitDelegateMessage)
        {
            MethodInfo methodInfo = _serverType.GetMethod(rabbitDelegateMessage.Method);

            try
            {
                var reply = methodInfo.Invoke(_server, rabbitDelegateMessage.Args);
                return(new RabbitResponseMessage(reply));
            }
            catch (TargetInvocationException e)
            {
                return(new RabbitResponseMessage(e.InnerException));
            }
        }
        private object CallServer(RabbitDelegateMessage message)
        {
            try
            {
                if (!IsConnected)
                {
                    throw new NotConnectedException();
                }
                RabbitResponseMessage response = Bus.Request <RabbitDelegateMessage, RabbitResponseMessage>(message);

                if (response.Exception != null)
                {
                    throw response.Exception;
                }
                var reply = response.Reply as IInternalValueProvider;
                return(reply.GetValue());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }