本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
}