예제 #1
0
파일: Requestor.cs 프로젝트: cunchy0/avro-1
            public void HandleResult(IList <MemoryStream> result)
            {
                var bbi   = new ByteBufferInputStream(result);
                var input = new BinaryDecoder(bbi);

                if (!requestor.ReadHandshake(input))
                {
                    // Resend the handshake and return
                    var handshake = new RpcRequest(request);

                    IList <MemoryStream> requestBytes = handshake.GetBytes(requestor.Local, requestor);
                    var transceiverCallback           = new TransceiverCallback <T>(requestor, handshake, callback,
                                                                                    local);

                    requestor.Transceiver.Transceive(requestBytes, transceiverCallback);
                    return;
                }

                // Read response; invoke callback
                var response = new Response(requestor, request, input);

                try
                {
                    Object responseObject;
                    try
                    {
                        responseObject = response.getResponse();
                    }
                    catch (Exception e)
                    {
                        if (callback != null)
                        {
                            callback.HandleException(e);
                        }
                        return;
                    }
                    if (callback != null)
                    {
                        callback.HandleResult((T)responseObject);
                    }
                }
                catch
                {
                    //LOG.error("Error in callback handler: " + t, t);
                }
            }
 public virtual void HandleException(Exception exception)
 {
     Error = exception;
     latch.Signal();
     if (chainedCallback != null)
     {
         chainedCallback.HandleException(exception);
     }
 }
예제 #3
0
        public void Transceive(IList<MemoryStream> request, ICallback<IList<MemoryStream>> callback)
        {
            if (request == null) throw new ArgumentNullException("request");

            try
            {
                IList<MemoryStream> response = Transceive(request);
                callback.HandleResult(response);
            }
            catch (IOException e)
            {
                callback.HandleException(e);
            }
        }
예제 #4
0
        public void Transceive(IList <MemoryStream> request, ICallback <IList <MemoryStream> > callback)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            try
            {
                IList <MemoryStream> response = Transceive(request);
                callback.HandleResult(response);
            }
            catch (IOException e)
            {
                callback.HandleException(e);
            }
        }