Handles asynchronous responses
Ejemplo n.º 1
0
 protected override void OnCommand(ITransport sender, Command command)
 {
     if (command is Response)
     {
         Response       response = (Response)command;
         FutureResponse future   = (FutureResponse)requestMap[response.CorrelationId];
         if (future != null)
         {
             if (response is ExceptionResponse)
             {
                 ExceptionResponse er          = (ExceptionResponse)response;
                 BrokerError       brokerError = er.Exception;
                 BrokerException   exception   = new BrokerException(brokerError);
                 this.exceptionHandler(this, exception);
             }
             future.Response = response;
         }
         else
         {
             if (command is ShutdownInfo)
             {
                 // lets shutdown
                 this.commandHandler(sender, command);
             }
             else
             {
                 Tracer.Error("Unknown response ID: " + response.CommandId + " for response: " + response);
             }
         }
     }
     else
     {
         this.commandHandler(sender, command);
     }
 }
Ejemplo n.º 2
0
        public override FutureResponse AsyncRequest(Command command)
        {
            command.CommandId        = GetNextCommandId();
            command.ResponseRequired = true;
            FutureResponse future = new FutureResponse();

            requestMap[command.CommandId] = future;
            next.Oneway(command);
            return(future);
        }
Ejemplo n.º 3
0
        public override FutureResponse AsyncRequest(Command command)
        {
            command.CommandId = GetNextCommandId();
            command.ResponseRequired = true;
            FutureResponse future = new FutureResponse();
            requestMap[command.CommandId] = future;
            next.Oneway(command);
            return future;

        }
Ejemplo n.º 4
0
        public override Response Request(Command command)
        {
            FutureResponse future   = AsyncRequest(command);
            Response       response = future.Response;

            if (response != null && response is ExceptionResponse)
            {
                ExceptionResponse er          = (ExceptionResponse)response;
                BrokerError       brokerError = er.Exception;
                if (brokerError == null)
                {
                    throw new BrokerException();
                }
                else
                {
                    throw new BrokerException(brokerError);
                }
            }
            return(response);
        }