本文整理汇总了C#中Msg.Move方法的典型用法代码示例。如果您正苦于以下问题:C# Msg.Move方法的具体用法?C# Msg.Move怎么用?C# Msg.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Msg
的用法示例。
在下文中一共展示了Msg.Move方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReceiveInternal
/// <summary>
/// If there's a pre-fetched message, snatch that.
/// Otherwise, dump any identity messages and get the first non-identity message,
/// or return false if there are no messages available.
/// </summary>
/// <param name="msg">a Msg to receive the message into</param>
/// <returns>false if there were no messages to receive</returns>
private bool ReceiveInternal(ref Msg msg)
{
// If there is a prefetched message, return it.
if (m_prefetched)
{
msg.Move(ref m_prefetchedMsg);
m_prefetched = false;
return true;
}
// DEALER socket doesn't use identities. We can safely drop it and
while (true)
{
bool isMessageAvailable = m_fairQueueing.Recv(ref msg);
if (!isMessageAvailable)
{
return false;
}
// Stop when we get any message that is not an Identity.
if (!msg.IsIdentity)
break;
}
return true;
}
示例2: XRecv
/// <summary>
/// Receive a message. The <c>Recv</c> method calls this lower-level method to do the actual receiving.
/// </summary>
/// <param name="msg">the <c>Msg</c> to receive the message into</param>
/// <returns><c>true</c> if the message was received successfully, <c>false</c> if there were no messages to receive</returns>
protected override bool XRecv(ref Msg msg)
{
// If there's already a message prepared by a previous call to zmq_poll,
// return it straight ahead.
if (m_hasMessage)
{
msg.Move(ref m_message);
m_hasMessage = false;
m_more = msg.HasMore;
return true;
}
// TODO: This can result in infinite loop in the case of continuous
// stream of non-matching messages which breaks the non-blocking recv
// semantics.
while (true)
{
// Get a message using fair queueing algorithm.
bool isMessageAvailable = m_fairQueueing.Recv(ref msg);
// If there's no message available, return immediately.
// The same when error occurs.
if (!isMessageAvailable)
{
return false;
}
// Check whether the message matches at least one subscription.
// Non-initial parts of the message are passed
if (m_more || !m_options.Filter || Match(msg))
{
m_more = msg.HasMore;
return true;
}
// Message doesn't match. Pop any remaining parts of the message
// from the pipe.
while (msg.HasMore)
{
isMessageAvailable = m_fairQueueing.Recv(ref msg);
Debug.Assert(isMessageAvailable);
}
}
}
示例3: XRecv
/// <summary>
/// Receive a message. The <c>Recv</c> method calls this lower-level method to do the actual receiving.
/// </summary>
/// <param name="msg">the <c>Msg</c> to receive the message into</param>
/// <returns><c>true</c> if the message was received successfully, <c>false</c> if there were no messages to receive</returns>
protected override bool XRecv(ref Msg msg)
{
if (m_prefetched)
{
if (!m_identitySent)
{
msg.Move(ref m_prefetchedId);
m_identitySent = true;
}
else
{
msg.Move(ref m_prefetchedMsg);
m_prefetched = false;
}
m_moreIn = msg.HasMore;
return true;
}
var pipe = new Pipe[1];
bool isMessageAvailable = m_fairQueueing.RecvPipe(pipe, ref msg);
// It's possible that we receive peer's identity. That happens
// after reconnection. The current implementation assumes that
// the peer always uses the same identity.
while (isMessageAvailable && msg.IsIdentity)
isMessageAvailable = m_fairQueueing.RecvPipe(pipe, ref msg);
if (!isMessageAvailable)
{
return false;
}
Debug.Assert(pipe[0] != null);
// If we are in the middle of reading a message, just return the next part.
if (m_moreIn)
m_moreIn = msg.HasMore;
else
{
// We are at the beginning of a message.
// Keep the message part we have in the prefetch buffer
// and return the ID of the peer instead.
m_prefetchedMsg.Move(ref msg);
m_prefetched = true;
byte[] identity = pipe[0].Identity;
msg.InitPool(identity.Length);
msg.Put(identity, 0, identity.Length);
msg.SetFlags(MsgFlags.More);
m_identitySent = true;
}
return true;
}
示例4: XRecv
/// <summary>
/// Receive a message. The <c>Recv</c> method calls this lower-level method to do the actual receiving.
/// </summary>
/// <param name="msg">the <c>Msg</c> to receive the message into</param>
/// <returns><c>true</c> if the message was received successfully, <c>false</c> if there were no messages to receive</returns>
protected override bool XRecv(ref Msg msg)
{
if (m_prefetched)
{
if (!m_identitySent)
{
msg.Move(ref m_prefetchedId);
m_identitySent = true;
}
else
{
msg.Move(ref m_prefetchedMsg);
m_prefetched = false;
}
return true;
}
var pipe = new Pipe[1];
bool isMessageAvailable = m_fairQueueing.RecvPipe(pipe, ref m_prefetchedMsg);
if (!isMessageAvailable)
{
return false;
}
Debug.Assert(pipe[0] != null);
Debug.Assert(!m_prefetchedMsg.HasMore);
// We have received a frame with TCP data.
// Rather than sending this frame, we keep it in prefetched
// buffer and send a frame with peer's ID.
byte[] identity = pipe[0].Identity;
msg.InitPool(identity.Length);
msg.Put(identity, 0, identity.Length);
msg.SetFlags(MsgFlags.More);
m_prefetched = true;
m_identitySent = true;
return true;
}