本文整理汇总了C#中NetMQ.zmq.Msg.InitEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# Msg.InitEmpty方法的具体用法?C# Msg.InitEmpty怎么用?C# Msg.InitEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetMQ.zmq.Msg
的用法示例。
在下文中一共展示了Msg.InitEmpty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Consume
protected override void Consume(PullSocket socket, int messageSize)
{
var msg = new Msg();
msg.InitEmpty();
for (int i = 0; i < MsgCount; i++)
{
socket.Receive(ref msg, SendReceiveOptions.None);
Debug.Assert(msg.Data.Length == messageSize, "Message length was different from expected size.");
Debug.Assert(msg.Data[msg.Size/2] == 0x42, "Message did not contain verification data.");
}
}
示例2: CleanPipes
// Remove any half processed messages. Flush unflushed messages.
// Call this function when engine disconnect to get rid of leftovers.
private void CleanPipes()
{
if (m_pipe != null)
{
// Get rid of half-processed messages in the out pipe. Flush any
// unflushed messages upstream.
m_pipe.Rollback();
m_pipe.Flush();
// Remove any half-read message from the in pipe.
while (m_incompleteIn)
{
var msg = new Msg();
msg.InitEmpty();
if (!PullMsg(ref msg))
{
Debug.Assert(!m_incompleteIn);
break;
}
msg.Close();
}
}
}
示例3: Read
public static MonitorEvent Read([NotNull] SocketBase s)
{
var msg = new Msg();
msg.InitEmpty();
s.Recv(ref msg, SendReceiveOptions.None);
int pos = 0;
ByteArraySegment data = msg.Data;
var @event = (SocketEvent)data.GetInteger(Endianness.Little, pos);
pos += 4;
var len = (int)data[pos++];
string addr = data.GetString(len, pos);
pos += len;
var flag = (int)data[pos++];
Object arg = null;
if (flag == ValueInteger)
{
arg = data.GetInteger(Endianness.Little, pos);
}
else if (flag == ValueChannel)
{
IntPtr value = s_sizeOfIntPtr == 4
? new IntPtr(data.GetInteger(Endianness.Little, pos))
: new IntPtr(data.GetLong(Endianness.Little, pos));
GCHandle handle = GCHandle.FromIntPtr(value);
AsyncSocket socket = null;
if (handle.IsAllocated)
{
socket = handle.Target as AsyncSocket;
}
handle.Free();
arg = socket;
}
return new MonitorEvent(@event, addr, arg);
}
示例4: PushMsg
public virtual bool PushMsg(ref Msg msg)
{
// First message to receive is identity (if required).
if (!m_identityReceived)
{
msg.SetFlags(MsgFlags.Identity);
m_identityReceived = true;
if (!m_options.RecvIdentity)
{
msg.Close();
msg.InitEmpty();
return true;
}
}
if (m_pipe != null && m_pipe.Write(ref msg))
{
msg.InitEmpty();
return true;
}
return false;
}