Пример #1
0
        /// <summary>
        /// Send the data to all BroadcastReceivers.
        /// </summary>
        /// <param name="data">The data to send.</param>
        public void Send(T data)
        {
            var messageList = PipelineDataConverter.PipelineMessage(data);

            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            foreach (var message in messageList)
            {
                _topology.SendToChildren(message, MessageType.Data);
            }
        }
Пример #2
0
        /// <summary>
        /// Receive a message from parent BroadcastSender.
        /// </summary>
        /// <param name="cancellationSource">The cancellation token for the data reading operation cancellation</param>
        /// <returns>The incoming message</returns>
        public T Receive(CancellationTokenSource cancellationSource = null)
        {
            PipelineMessage <T> message;
            var messageList = new List <PipelineMessage <T> >();

            do
            {
                message = _topology.ReceiveFromParent(cancellationSource);

                if (_topology.HasChildren())
                {
                    _topology.SendToChildren(message, MessageType.Data);
                }

                messageList.Add(message);
            }while (!message.IsLast);

            return(PipelineDataConverter.FullMessage(messageList));
        }