예제 #1
0
        /**
         * Implements the IReplyHandler (also provides some light-weight statistics)
         */
        public bool HandleReply(ReqrepManager man, ReqrepManager.ReqrepType rt,
                                int mid, PType prot, MemBlock payload, ISender ret_path,
                                ReqrepManager.Statistics statistics, object state)
        {
            RpcRequestState rs = (RpcRequestState)state;
            //ISender target = rs.RpcTarget;
            Channel bq = rs.Results;

            if (bq != null)
            {
                object    data = AdrConverter.Deserialize(payload);
                RpcResult res  = new RpcResult(ret_path, data, statistics);
                //handle possible exception:
                try {
                    bq.Enqueue(res);
                    //Keep listening unless the queue is closed
                    return(!bq.Closed);
                }
                catch (System.InvalidOperationException) {
                    //The queue is closed, stop listening for more results:
                    return(false);
                }
            }
            else
            {
                //If they didn't even pass us a queue, I guess they didn't want to
                //listen too long
                return(false);
            }
        }
예제 #2
0
파일: RpcManager.cs 프로젝트: pcbing/brunet
 public RpcResult(ISender ret_path, object res, ReqrepManager.Statistics stats)
 {
     _ret_path   = ret_path;
     _result     = res;
     _statistics = stats;
 }