当前位置: 首页>>代码示例>>C#>>正文


C# RequestState.Send方法代码示例

本文整理汇总了C#中RequestState.Send方法的典型用法代码示例。如果您正苦于以下问题:C# RequestState.Send方法的具体用法?C# RequestState.Send怎么用?C# RequestState.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RequestState的用法示例。


在下文中一共展示了RequestState.Send方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendRequest

  /**
   * @param sender how to send the request
   * @param reqt the type of request to make
   * @param data the data to encapsulate and send
   * @param reply the handler to handle the reply
   * @param state some state object to attach to this request
   * @return the identifier for this request
   *
   */
  public int SendRequest(ISender sender, ReqrepType reqt, ICopyable data,
		         IReplyHandler reply, object state)
  {
    if ( reqt != ReqrepType.Request && reqt != ReqrepType.LossyRequest ) {
      throw new Exception("Not a request");
    }
    RequestState rs = new RequestState();
    rs.Sender = sender;
    rs.ReplyHandler = reply;
    rs.RequestType = reqt;
    rs.UserState = state;
    lock( _sync ) {
      //Get the index 
      int next_req = 0;
      do {
        next_req = _rand.Next();
      } while( _req_state_table.ContainsKey( next_req ) );
      /*
       * Now we store the request
       */
      rs.RequestID = next_req;
      rs.Request = MakeRequest(reqt, next_req, data);
      _req_state_table[ rs.RequestID ] = rs;
    }
#if REQREP_DEBUG
    Console.Error.WriteLine("[ReqrepClient: {0}] Sending a request: {1} to node: {2}",
		      _info, rs.RequestID, sender);
#endif
    try {
      rs.Send();
      return rs.RequestID;
    }
    catch {
      //Clean up:
      StopRequest(rs.RequestID, reply);
      throw;
    }
  }
开发者ID:xujyan,项目名称:brunet,代码行数:47,代码来源:ReqrepManager.cs

示例2: SendRequest

  /**
   * @param sender how to send the request
   * @param reqt the type of request to make
   * @param data the data to encapsulate and send
   * @param reply the handler to handle the reply
   * @param state some state object to attach to this request
   * @return the identifier for this request
   *
   */
  public int SendRequest(ISender sender, ReqrepType reqt, ICopyable data,
		         IReplyHandler reply, object state)
  {
    if ( reqt != ReqrepType.Request && reqt != ReqrepType.LossyRequest ) {
      throw new Exception("Not a request");
    }
    TimeSpan timeout = _to_mgr.GetTimeOutFor(sender);
    RequestState rs = new RequestState(timeout, _to_mgr.AckedTimeOut);
    rs.Sender = sender;
    rs.ReplyHandler = reply;
    rs.RequestType = reqt;
    rs.UserState = state;
    lock( _sync ) {
      rs.RequestID = _req_state_table.GenerateID(rs);
      rs.Request = MakeRequest(reqt, rs.RequestID, data);
    }
    //Make sure that when we drop the lock, rs is totally initialized
#if REQREP_DEBUG
    Console.Error.WriteLine("[ReqrepClient: {0}] Sending a request: {1} to node: {2}",
		      _info, rs.RequestID, sender);
#endif
    try {
      rs.Send();
      return rs.RequestID;
    }
    catch(SendException sx) {
      if( sx.IsTransient ) {
        //I guess we will just try to resend again in the future:
        return rs.RequestID;
      }
      else {
        //This is certainly going to fail, so fail now:
        StopRequest(rs.RequestID, reply);
        throw;
      }
    }
    catch {
      //Clean up:
      StopRequest(rs.RequestID, reply);
      throw;
    }
  }
开发者ID:pstjuste,项目名称:brunet,代码行数:51,代码来源:ReqrepManager.cs

示例3: SendRequest

  /**
   * @param sender how to send the request
   * @param reqt the type of request to make
   * @param data the data to encapsulate and send
   * @param reply the handler to handle the reply
   * @param state some state object to attach to this request
   * @return the identifier for this request
   *
   */
  public int SendRequest(ISender sender, ReqrepType reqt, ICopyable data,
		         IReplyHandler reply, object state)
  {
    if ( reqt != ReqrepType.Request && reqt != ReqrepType.LossyRequest ) {
      throw new Exception("Not a request");
    }
    TimeSpan timeout = sender is Edge ? _edge_reqtimeout : _nonedge_reqtimeout;
    RequestState rs = new RequestState(timeout, _acked_reqtimeout);
    rs.Sender = sender;
    rs.ReplyHandler = reply;
    rs.RequestType = reqt;
    rs.UserState = state;
    lock( _sync ) {
      rs.RequestID = _req_state_table.GenerateID(rs);
      rs.Request = MakeRequest(reqt, rs.RequestID, data);
    }
    //Make sure that when we drop the lock, rs is totally initialized
#if REQREP_DEBUG
    Console.Error.WriteLine("[ReqrepClient: {0}] Sending a request: {1} to node: {2}",
		      _info, rs.RequestID, sender);
#endif
    try {
      rs.Send();
      return rs.RequestID;
    }
    catch {
      //Clean up:
      StopRequest(rs.RequestID, reply);
      throw;
    }
  }
开发者ID:hseom,项目名称:brunet-1,代码行数:40,代码来源:ReqrepManager.cs


注:本文中的RequestState.Send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。