當前位置: 首頁>>代碼示例>>C#>>正文


C# Msg.InitEmpty方法代碼示例

本文整理匯總了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.");
            }
        }
開發者ID:bbqchickenrobot,項目名稱:netmq,代碼行數:12,代碼來源:ThroughputBenchmark.cs

示例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();
                }
            }
        }
開發者ID:bbqchickenrobot,項目名稱:netmq,代碼行數:26,代碼來源:SessionBase.cs

示例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);
        }
開發者ID:bbqchickenrobot,項目名稱:netmq,代碼行數:43,代碼來源:MonitorEvent.cs

示例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;
        }
開發者ID:bbqchickenrobot,項目名稱:netmq,代碼行數:24,代碼來源:SessionBase.cs


注:本文中的NetMQ.zmq.Msg.InitEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。