示例#1
0
        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);
        }
示例#2
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));
            });
        }
示例#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));
            });
        }
示例#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);
        }