本文整理汇总了C#中NetMQMessage.PushEmptyFrame方法的典型用法代码示例。如果您正苦于以下问题:C# NetMQMessage.PushEmptyFrame方法的具体用法?C# NetMQMessage.PushEmptyFrame怎么用?C# NetMQMessage.PushEmptyFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetMQMessage
的用法示例。
在下文中一共展示了NetMQMessage.PushEmptyFrame方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmptyFrames
public void EmptyFrames()
{
var message = new NetMQMessage();
message.Append("middle");
message.AppendEmptyFrame();
message.PushEmptyFrame();
Assert.AreEqual("middle", message[1].ConvertToString());
Assert.AreEqual(0, message[0].MessageSize);
Assert.AreEqual(0, message[2].MessageSize);
Assert.AreEqual(3, message.FrameCount);
}
示例2: Send
/// <summary>
/// send a asyncronous request to a broker for a specific service without receiving a reply
///
/// there is no retry logic
/// according to the verbose flag it reports about its activities
/// </summary>
/// <param name="serviceName">the name of the service requested</param>
/// <param name="request">the request message to process by service</param>
/// <exception cref="ApplicationException">serviceName must not be empty or null.</exception>
/// <exception cref="ApplicationException">the request must not be null</exception>
public void Send([NotNull] string serviceName, NetMQMessage request)
{
// TODO criar tabela de pedidos ongoing
if (string.IsNullOrWhiteSpace(serviceName))
throw new ApplicationException("serviceName must not be empty or null.");
if (ReferenceEquals(request, null))
throw new ApplicationException("the request must not be null");
// memorize it for the event handler
m_serviceName = serviceName;
// if for any reason the socket is NOT connected -> connect it!
if (!m_connected)
Connect();
var message = new NetMQMessage(request);
// prefix the request according to MDP specs
// Frame 1: Empty Frame, because DEALER socket needs to emulate a REQUEST socket to comunicate with ROUTER socket
// Frame 2: "MDPCxy" (six bytes MDP/Client x.y)
// Frame 3: service name as printable string
// Frame 4: request
message.Push(serviceName);
message.Push(m_mdpClient);
message.PushEmptyFrame();
Log($"[CLIENT INFO] sending {message} to service {serviceName}");
m_client.SendMultipartMessage(message); // Or TrySend!? ErrorHandling!?
}
示例3: Wrap
/// <summary>
/// Wrap a message with the identity and an empty frame
/// </summary>
/// <returns>new created message</returns>
private static NetMQMessage Wrap(NetMQFrame identity, NetMQMessage msg)
{
var result = new NetMQMessage(msg);
result.PushEmptyFrame();
result.Push(identity);
return result;
}
示例4: Send
/// <summary>
/// send a asyncronous request to a broker for a specific service without receiving a reply
///
/// there is no retry logic
/// according to the verbose flag it reports about its activities
/// </summary>
/// <param name="serviceName">the name of the service requested</param>
/// <param name="request">the request message to process by service</param>
/// <exception cref="ApplicationException">serviceName must not be empty or null.</exception>
/// <exception cref="ApplicationException">the request must not be null</exception>
public Guid Send([NotNull] string serviceName, NetMQMessage request, SendOptions options = null)
{
if (string.IsNullOrWhiteSpace(serviceName))
throw new ApplicationException("serviceName must not be empty or null.");
if (ReferenceEquals(request, null))
throw new ApplicationException("the request must not be null");
if (ReferenceEquals(options, null))
{
options.Timeout = m_defaultTimeOutPerRequest;
options.Attempts = 1;
}
// memorize it for the event handler
m_serviceName = serviceName; // TODO this is wrong because I can be sending multiple serviceNames
// if for any reason the socket is NOT connected -> connect it!
if (!m_connected)
Connect();
var message = new NetMQMessage(request);
// prefix the request according to MDP specs
// Frame 1: Empty Frame, because DEALER socket needs to emulate a REQUEST socket to comunicate with ROUTER socket
// Frame 2: "MDPCxy" (six bytes MDP/Client x.y)
// Frame 3: service name as printable string
// Frame 4: request
message.Push(serviceName);
message.Push(m_mdpClient);
message.PushEmptyFrame();
var req = new Request(serviceName, message, options.Timeout, options.Attempts);
var reqId = m_requestQueue.EnqueueRequest(req);
Log($"[CLIENT INFO] sending requestId: {reqId} message: {message} to service {serviceName}");
return reqId;
}