public void TestBroadcastPooledByteBuffer()
        {
            var buffer1 = _pool.Acquire();
            var buffer2 = _pool.Acquire();
            var buffer3 = _pool.Acquire();

            var rawMessage1 = BuildRawMessageBuffer((MemoryStream)buffer1.AsStream(), _message1);

            BytesFrom(rawMessage1, (MemoryStream)buffer1.AsStream());
            var rawMessage2 = BuildRawMessageBuffer((MemoryStream)buffer2.AsStream(), _message2);

            BytesFrom(rawMessage2, (MemoryStream)buffer2.AsStream());
            var rawMessage3 = BuildRawMessageBuffer((MemoryStream)buffer3.AsStream(), _message3);

            BytesFrom(rawMessage3, (MemoryStream)buffer3.AsStream());

            _outbound.Broadcast(buffer1);
            _outbound.Broadcast(buffer2);
            _outbound.Broadcast(buffer3);

            foreach (var channel in _channelProvider.AllOtherNodeChannels.Values)
            {
                var mock = (MockManagedOutboundChannel)channel;

                Assert.Equal(_message1, mock.Writes[0]);
                Assert.Equal(_message2, mock.Writes[1]);
                Assert.Equal(_message3, mock.Writes[2]);
            }
        }
Exemple #2
0
        private void ReadConsume(SslStream sslStream)
        {
            var pooledBuffer = _readBufferPool.Acquire();
            var readBuffer   = pooledBuffer.ToArray();

            try
            {
                // Create the state object.
                var state = new StateObject(sslStream, readBuffer, pooledBuffer);
                sslStream.BeginRead(readBuffer, 0, readBuffer.Length, ReceiveCallback, state);
                _receiveDone.WaitOne();
            }
            catch (Exception e)
            {
                _logger.Error("Cannot begin receiving on the channel", e);
                throw;
            }
        }
Exemple #3
0
        public void Broadcast(RawMessage message)
        {
            var buffer = _pool.Acquire();

            Broadcast(BytesFrom(message, buffer));
        }