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


C# NetMQMessage.PushEmptyFrame方法代码示例

本文整理汇总了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);
        }
开发者ID:ezhuo,项目名称:netmq,代码行数:13,代码来源:MessageTests.cs

示例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!?
        }
开发者ID:GrabCAD,项目名称:netmq,代码行数:41,代码来源:MDPClientAsync.cs

示例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;
        }
开发者ID:cjkao,项目名称:netmq,代码行数:13,代码来源:Program.cs

示例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;
        }
开发者ID:,项目名称:,代码行数:47,代码来源:


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