当前位置: 首页>>代码示例>>C#>>正文


C# Msg.ResetFlags方法代码示例

本文整理汇总了C#中NetMQ.zmq.Msg.ResetFlags方法的典型用法代码示例。如果您正苦于以下问题:C# Msg.ResetFlags方法的具体用法?C# Msg.ResetFlags怎么用?C# Msg.ResetFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetMQ.zmq.Msg的用法示例。


在下文中一共展示了Msg.ResetFlags方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RawMessageReady

        bool RawMessageReady()
        {
            //  Destroy content of the old message.
            m_inProgress = null;

            //  Read new message. If there is none, return false.
            //  Note that new state is set only if write is successful. That way
            //  unsuccessful write will cause retry on the next state machine
            //  invocation.
            if (m_msgSource == null)
            {
                return false;
            }

            m_inProgress = m_msgSource.PullMsg();

            if (m_inProgress == null)
                return false;

            m_inProgress.ResetFlags(MsgFlags.Shared | MsgFlags.More | MsgFlags.Identity);

            NextStep(null, 0, RawMessageSizeReadyState, true);

            return true;
        }
开发者ID:JayShelton,项目名称:netmq,代码行数:25,代码来源:RawEncoder.cs

示例2: Send

        public void Send(Msg msg, SendReceiveOptions flags)
        {
            if (m_ctxTerminated)
            {
                throw TerminatingException.Create();
            }

            //  Check whether message passed to the function is valid.
            if (msg == null)
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            //  Process pending commands, if any.
            ProcessCommands(0, true);

            //  Clear any user-visible flags that are set on the message.
            msg.ResetFlags(MsgFlags.More);

            //  At this point we impose the flags on the message.
            if ((flags & SendReceiveOptions.SendMore) > 0)
                msg.SetFlags(MsgFlags.More);

            //  Try to send the message.

            bool isMessageSent = XSend(msg, flags);

            if (isMessageSent)
            {
                return;
            }

            //  In case of non-blocking send we'll simply propagate
            //  the error - including EAGAIN - up the stack.
            if ((flags & SendReceiveOptions.DontWait) > 0 || m_options.SendTimeout == 0)
                throw AgainException.Create();

            //  Compute the time when the timeout should occur.
            //  If the timeout is infite, don't care.
            int timeout = m_options.SendTimeout;
            long end = timeout < 0 ? 0 : (Clock.NowMs() + timeout);

            //  Oops, we couldn't send the message. Wait for the next
            //  command, process it and try to send the message again.
            //  If timeout is reached in the meantime, return EAGAIN.
            while (true)
            {
                ProcessCommands(timeout, false);

                isMessageSent = XSend(msg, flags);
                if (isMessageSent)
                    break;

                if (timeout > 0)
                {
                    timeout = (int)(end - Clock.NowMs());
                    if (timeout <= 0)
                    {
                        throw AgainException.Create();
                    }
                }
            }
        }
开发者ID:hecwow,项目名称:netmq,代码行数:63,代码来源:SocketBase.cs

示例3: Send

        public bool Send(Msg msg, SendRecieveOptions flags)
        {
            if (m_ctxTerminated)
            {
                ZError.ErrorNumber = (ErrorNumber.ETERM);
                return false;
            }

            //  Check whether message passed to the function is valid.
            if (msg == null)
            {
                ZError.ErrorNumber = (ErrorNumber.EFAULT);
                throw new ArgumentException();
            }

            //  Process pending commands, if any.
            bool rc = ProcessCommands(0, true);
            if (!rc)
                return false;

            //  Clear any user-visible flags that are set on the message.
            msg.ResetFlags(MsgFlags.More);

            //  At this point we impose the flags on the message.
            if ((flags & SendRecieveOptions.SendMore) > 0)
                msg.SetFlags(MsgFlags.More);

            //  Try to send the message.
            rc = XSend(msg, flags);
            if (rc)
                return true;
            if (!ZError.IsError(ErrorNumber.EAGAIN))
                return false;

            //  In case of non-blocking send we'll simply propagate
            //  the error - including EAGAIN - up the stack.
            if ((flags & SendRecieveOptions.DontWait) > 0 || m_options.SendTimeout == 0)
                return false;

            //  Compute the time when the timeout should occur.
            //  If the timeout is infite, don't care.
            int timeout = m_options.SendTimeout;
            long end = timeout < 0 ? 0 : (Clock.NowMs() + timeout);

            //  Oops, we couldn't send the message. Wait for the next
            //  command, process it and try to send the message again.
            //  If timeout is reached in the meantime, return EAGAIN.
            while (true)
            {
                if (!ProcessCommands(timeout, false))
                    return false;

                rc = XSend(msg, flags);
                if (rc)
                    break;

                if (!ZError.IsError(ErrorNumber.EAGAIN))
                    return false;

                if (timeout > 0)
                {
                    timeout = (int)(end - Clock.NowMs());
                    if (timeout <= 0)
                    {
                        ZError.ErrorNumber = (ErrorNumber.EAGAIN);
                        return false;
                    }
                }
            }
            return true;
        }
开发者ID:oskarwkarlsson,项目名称:netmq,代码行数:71,代码来源:SocketBase.cs

示例4: Send

        /// <summary>
        /// Transmit the given Msg across the message-queueing system.
        /// If the msg fails to immediately send, then - if DontWait is specified and no SendTimeout was set
        /// then throw an AgainException.
        /// </summary>
        /// <param name="msg">the Msg to transmit</param>
        /// <param name="flags">a SendReceiveOptions: either don't specify DontWait, or set a timeout</param>
        public void Send(ref Msg msg, SendReceiveOptions flags)
        {
            CheckContextTerminated();

            //  Check whether message passed to the function is valid.
            if (!msg.IsInitialised)
                throw new FaultException("SocketBase.Send passed an uninitialised Msg.");

            //  Process pending commands, if any.
            ProcessCommands(0, true);

            //  Clear any user-visible flags that are set on the message.
            msg.ResetFlags(MsgFlags.More);

            //  At this point we impose the flags on the message.
            if ((flags & SendReceiveOptions.SendMore) > 0)
                msg.SetFlags(MsgFlags.More);

            //  Try to send the message.
            bool isMessageSent = XSend(ref msg);

            if (isMessageSent)
                return;

            //  In case of non-blocking send we'll simply propagate
            //  the error - including EAGAIN - up the stack.
            bool isDontWaitSet = (flags & SendReceiveOptions.DontWait) > 0;
            if (isDontWaitSet || m_options.SendTimeout == 0)
            {
            #if DEBUG
                string xMsg;
                if (isDontWaitSet && m_options.SendTimeout == 0)
                    xMsg = "SocketBase.Send failed, and DontWait is true AND SendTimeout is 0.";
                else if (isDontWaitSet)
                    xMsg = "SocketBase.Send failed and DontWait is specified.";
                else
                    xMsg = "SocketBase.Send failed and no SendTimeout is specified.";
                throw new AgainException(innerException: null, message: xMsg);
            #else
                throw new AgainException(innerException: null, message: "SocketBase.Send failed");
            #endif
            }

            //  Compute the time when the timeout should occur.
            //  If the timeout is infinite, don't care.
            int timeout = m_options.SendTimeout;
            long end = timeout < 0 ? 0 : (Clock.NowMs() + timeout);

            //  Oops, we couldn't send the message. Wait for the next
            //  command, process it and try to send the message again.
            //  If timeout is reached in the meantime, return EAGAIN.
            while (true)
            {
                ProcessCommands(timeout, false);

                isMessageSent = XSend(ref msg);

                if (isMessageSent)
                    break;

                if (timeout <= 0)
                    continue;

                timeout = (int)(end - Clock.NowMs());

                if (timeout <= 0)
                    throw new AgainException(innerException: null, message: "SocketBase.Send failed and timeout <= 0");
            }
        }
开发者ID:bbqchickenrobot,项目名称:netmq,代码行数:76,代码来源:SocketBase.cs

示例5: XSend

        protected override bool XSend(Msg msg, SendReceiveOptions flags)
        {
            //  If this is the first part of the message it's the ID of the
              //  peer to send the message to.
              if (!m_moreOut)
              {
            Debug.Assert(m_currentOut == null);

            //  If we have malformed message (prefix with no subsequent message)
            //  then just silently ignore it.
            //  TODO: The connections should be killed instead.
            if (msg.HasMore)
            {
              //  Find the pipe associated with the identity stored in the prefix.
              //  If there's no such pipe just silently ignore the message, unless
              //  mandatory is set.
              Blob identity = new Blob(msg.Data);
              Outpipe op;

              if (m_outpipes.TryGetValue(identity, out op))
              {
            m_currentOut = op.Pipe;
            if (!m_currentOut.CheckWrite())
            {
              op.Active = false;
              m_currentOut = null;
              return false;
            }
              }
              else
              {
            throw NetMQException.Create(ErrorCode.EHOSTUNREACH);
              }
            }

            m_moreOut = true;

            return true;
              }

              //  Ignore the MORE flag
              msg.ResetFlags(MsgFlags.More);

              //  This is the last part of the message.
              m_moreOut = false;

              //  Push the message into the pipe. If there's no out pipe, just drop it.
              if (m_currentOut != null)
              {
            if (msg.Size == 0)
            {
              m_currentOut.Terminate(false);
              m_currentOut = null;
              return true;
            }

            bool ok = m_currentOut.Write(msg);
            if (ok)
            {
              m_currentOut.Flush();
            }

            m_currentOut = null;
              }
              else
              {
              }

              //  Detach the message from the data buffer.

              return true;
        }
开发者ID:hecwow,项目名称:netmq,代码行数:72,代码来源:Stream.cs


注:本文中的NetMQ.zmq.Msg.ResetFlags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。