public long AddPublication(string channel, int streamId)
        {
            long correlationId = _toDriverCommandBuffer.NextCorrelationId();

            _publicationMessage.CorrelationId(correlationId);

            _publicationMessage
            .StreamId(streamId)
            .Channel(channel);

            if (!_toDriverCommandBuffer.Write(ControlProtocolEvents.ADD_PUBLICATION, _buffer, 0,
                                              _publicationMessage.Length()))
            {
                throw new AeronException("Could not write add publication command");
            }

            return(correlationId);
        }
        private void ThreadSendsChannelMessage(Action sendMessage, int expectedMsgTypeId)
        {
            sendMessage();

            AssertReadsOneMessage((msgTypeId, buffer, index, length) =>
            {
                PublicationMessageFlyweight publicationMessage = new PublicationMessageFlyweight();
                publicationMessage.Wrap(buffer, index);
                Assert.That(msgTypeId, Is.EqualTo(expectedMsgTypeId));
                Assert.That(publicationMessage.Channel(), Is.EqualTo(CHANNEL));
                Assert.That(publicationMessage.StreamId(), Is.EqualTo(STREAM_ID));
            });
        }
Exemple #3
0
        private void ThreadSendsChannelMessage(Action sendMessage, int expectedMsgTypeId)
        {
            sendMessage();

            AssertReadsOneMessage((msgTypeId, buffer, index, length) =>
            {
                PublicationMessageFlyweight publicationMessage = new PublicationMessageFlyweight();
                publicationMessage.Wrap(buffer, index);
                Assert.That(msgTypeId, Is.EqualTo(expectedMsgTypeId));
                Assert.That(publicationMessage.Channel(), Is.EqualTo(CHANNEL));
                Assert.That(publicationMessage.StreamId(), Is.EqualTo(STREAM_ID));
            });
        }
Exemple #4
0
        public virtual long AddPublication(string channel, int streamId)
        {
            long correlationId = _toDriverCommandBuffer.NextCorrelationId();

            _publicationMessage.ClientId(_clientId).CorrelationId(correlationId);

            _publicationMessage.StreamId(streamId).Channel(channel);

            if (!_toDriverCommandBuffer.Write(ControlProtocolEvents.ADD_PUBLICATION, _buffer, 0, _publicationMessage.Length()))
            {
                throw new InvalidOperationException("could not write publication message");
            }

            return(correlationId);
        }