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


C# NetMQSocket.SendMultipartMessage方法代码示例

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


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

示例1: Send

        public Action<NetMQMessage> Send(NetMQSocket socket, PendingResRequest pendingRequest, Guid requestId)
        {
            var pending = (PendingResRequest<QueryEventsForStreamResponse>) pendingRequest;
            var msg = new NetMQMessage();
            msg.AppendEmptyFrame();
            msg.Append(ResProtocol.ResClient01);
            msg.Append(ResCommands.QueryEventsByStream);
            msg.Append(requestId.ToByteArray());
            msg.Append(_context);
            msg.Append(_stream);
            msg.Append(_fromVersion.ToNetMqFrame());
            msg.Append(_maxVersion.ToNetMqFrame());

            socket.SendMultipartMessage(msg);

            return m =>
            {
                var command = m.Pop().ConvertToString();

                if (command == ResCommands.Error)
                {
                    var errorCode = m.Pop().ConvertToString();
                    var errorDetails = m.Pop().ConvertToString();
                    ErrorResolver.RaiseException(errorCode, errorDetails, pending.SetException);
                    return;
                }

                if (command != ResCommands.QueryEventsByStreamResponse)
                    pending.SetException(new UnsupportedCommandException(command));

                var count = m.PopInt32();

                var events = new EventInStorage[count];

                for (var i = 0; i < count; i++)
                {
                    var id = new Guid(m.Pop().ToByteArray());
                    var streamId = m.Pop().ConvertToString();
                    var context = m.Pop().ConvertToString();
                    var sequence = m.PopInt64();
                    var timestamp = m.PopDateTime();;
                    var type = m.PopString();
                    var headers = m.PopStringOrNull();
                    var body = m.PopString();

                    events[i] = new EventInStorage(context, streamId, sequence, type, id, headers, body, timestamp);
                }

                var result = new QueryEventsForStreamResponse(_context, _stream, events);
                pending.SetResult(result);
            };
        }
开发者ID:heartysoft,项目名称:res,代码行数:52,代码来源:QueryEventsForStreamRequest.cs

示例2: ProcessMessage

        public void ProcessMessage(NetMQMessage message, NetMQSocket socket)
        {
            var sender = new List<NetMQFrame>(message.FrameCount);

            for (int i = 0; i < message.FrameCount; i++)
            {
                var frame = message[i];
                if (frame.BufferSize == 0)
                    break;

                sender.Add(frame);
            }

            var protocolFrame = message[sender.Count + 1];
            var commandFrame = message[sender.Count + 2];
            var requestId = message[sender.Count + 3];

            try
            {
                _processor.ProcessMessage(message, socket);
            }
            catch (Exception e)
            {
                Log.Warn("[EHMessageProcessor] Error processing message.", e);
                var entry = _errorResolver.GetError(e);

                if (entry != null)
                {
                    var msg = new NetMQMessage();

                    foreach (var frame in sender)
                    {
                        msg.Append(frame);
                    }

                    msg.AppendEmptyFrame();

                    msg.Append(protocolFrame);
                    msg.Append(requestId);
                    msg.Append(ResCommands.Error);
                    msg.Append(entry.ErrorCode.ToString(CultureInfo.InvariantCulture));
                    msg.Append(entry.Message);
                    socket.SendMultipartMessage(msg);
                }
            }
        }
开发者ID:heartysoft,项目名称:res,代码行数:46,代码来源:ErrorHandlingMessageProcessor.cs

示例3: Send

        public Action<NetMQMessage> Send(NetMQSocket socket, PendingResRequest pendingRequest, Guid requestId)
        {
            var pending = (PendingResRequest<CommitResponse>) pendingRequest;

            var msg = new NetMQMessage();
            msg.AppendEmptyFrame();
            msg.Append(ResProtocol.ResClient01);
            msg.Append(ResCommands.AppendCommit);
            msg.Append(requestId.ToByteArray());
            msg.Append(Context);
            msg.Append(Stream);
            msg.Append(ExpectedVersion.ToNetMqFrame());
            msg.Append(Events.Length.ToNetMqFrame());

            foreach (var e in Events)
            {
                msg.Append(e.EventId.ToByteArray());
                msg.Append(e.Timestamp.ToNetMqFrame());
                msg.Append(e.TypeTag);
                msg.Append(e.Headers.ToNetMqFrame());
                msg.Append(e.Body);
            }

            socket.SendMultipartMessage(msg);

            return m =>
            {
                var command = m.Pop().ConvertToString();

                if (command == ResCommands.Error)
                {
                    var errorCode = m.Pop().ConvertToString();
                    var errorDetails = m.Pop().ConvertToString();
                    ErrorResolver.RaiseException(errorCode, errorDetails, pending.SetException);
                    return;
                }

                if (command != ResCommands.CommitResult)
                    pending.SetException(new UnsupportedCommandException(command));

                var commitId = new Guid(m.Pop().ToByteArray());
                var result = new CommitResponse(commitId);
                pending.SetResult(result);
            };
        }
开发者ID:heartysoft,项目名称:res,代码行数:45,代码来源:CommitRequest.cs

示例4: Send

        public void Send(NetMQSocket socket)
        {
            var msg = new NetMQMessage();
            msg.Append(_context.Sender);
            msg.AppendEmptyFrame();
            msg.Append(_protocol);
            msg.Append(_context.RequestId);

            if (_error == null)
            {
                msg.Append(ResCommands.CommitResult);
                msg.Append(_context.CommitId.ToByteArray());
            }
            else
            {
                msg.Append(ResCommands.Error);
                msg.Append(_error.ErrorCode.ToString(CultureInfo.InvariantCulture));
                msg.Append(_error.Message);
            }

            socket.SendMultipartMessage(msg);
        }
开发者ID:heartysoft,项目名称:res,代码行数:22,代码来源:CommitResult.cs

示例5: Send

 public void Send(NetMQSocket socket)
 {
     socket.SendMultipartMessage(_msg);
 }
开发者ID:heartysoft,项目名称:res,代码行数:4,代码来源:QueryEventsForStreamLoaded.cs

示例6: Send

        public Action<NetMQMessage> Send(NetMQSocket socket, PendingResRequest pendingRequest, Guid requestId)
        {
            var pending = (PendingResRequest<QueuedEventsResponse>) pendingRequest;

            var msg = new NetMQMessage();
            msg.AppendEmptyFrame();
            msg.Append(ResProtocol.ResClient01);
            msg.Append(ResCommands.AcknowledgeQueue);
            msg.Append(requestId.ToByteArray());

            msg.Append(_context);
            msg.Append(_queueId);
            msg.Append(_subscriberId);
            msg.Append(_allocationId.ToNetMqFrame());
            msg.Append(_allocationBatchSize.ToNetMqFrame());
            msg.Append(_allocationTimeoutInMilliseconds.ToNetMqFrame());

            socket.SendMultipartMessage(msg);

            return m =>
            {
                var command = m.Pop().ConvertToString();

                if (command == ResCommands.Error)
                {
                    var errorCode = m.Pop().ConvertToString();
                    var errorDetails = m.Pop().ConvertToString();
                    ErrorResolver.RaiseException(errorCode, errorDetails, pending.SetException);
                    return;
                }

                if (command != ResCommands.QueuedEvents)
                    pending.SetException(new UnsupportedCommandException(command));

                var queueContext = m.Pop().ConvertToString();
                var queueId = m.Pop().ConvertToString();
                var subscriberId = m.Pop().ConvertToString();
                var time = m.PopDateTime();
                var allocationId = m.PopNullableInt64();
                var count = m.PopInt32();

                var events = new EventInStorage[count];

                for (var i = 0; i < count; i++)
                {
                    var id = new Guid(m.Pop().ToByteArray());
                    var streamId = m.Pop().ConvertToString();
                    var context = m.Pop().ConvertToString();
                    var sequence = m.PopInt64();
                    var timestamp = m.PopDateTime();
                    var type = m.PopString();
                    var headers = m.PopStringOrNull();
                    var body = m.PopString();

                    events[i] = new EventInStorage(context, streamId, sequence, type, id, headers, body, timestamp);
                }

                var result = new QueuedEventsResponse(queueContext, queueId, subscriberId, time, allocationId, events);
                pending.SetResult(result);
            };
        }
开发者ID:heartysoft,项目名称:res,代码行数:61,代码来源:AcknowledgeQueueAndFetchNextRequest.cs


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