コード例 #1
0
        public int GetResponseChannel(IMutableDirectBuffer dst, int dstOffset, int length)
        {
            int headerLength = 4;
            int limit        = _parentMessage.Limit();
            int dataLength   = (int)unchecked ((uint)_buffer.GetInt(limit, ByteOrder.LittleEndian));
            int bytesCopied  = Math.Min(length, dataLength);

            _parentMessage.Limit(limit + headerLength + dataLength);
            _buffer.GetBytes(limit + headerLength, dst, dstOffset, bytesCopied);

            return(bytesCopied);
        }
コード例 #2
0
        private static void OnParseMessage(IDirectBuffer buffer, int offset, int length, Header header)
        {
            byte[] buf = new byte[length];
            buffer.GetBytes(offset, buf);
            var response = Encoding.UTF8.GetString(buf);

            Log?.WriteLine($"response: {response}");
        }
コード例 #3
0
        /// <summary>
        /// Append a source buffer to the end of the internal buffer, resizing the internal buffer as required.
        /// </summary>
        /// <param name="srcBuffer"> from which to copy. </param>
        /// <param name="srcOffset"> in the source buffer from which to copy. </param>
        /// <param name="length"> in bytes to copy from the source buffer. </param>
        /// <returns> the builder for fluent API usage. </returns>
        public BufferBuilder Append(IDirectBuffer srcBuffer, int srcOffset, int length)
        {
            EnsureCapacity(length);

            srcBuffer.GetBytes(srcOffset, _buffer, _limit, length);
            _limit += length;

            return(this);
        }
コード例 #4
0
        private void CompleteMessageReceived(IDirectBuffer buffer, int offset, int length, Header header)
        {
            var data = new byte[length];

            buffer.GetBytes(offset, data);
//
//            var d = Util.Deserialize<TestMessage>(data);
//            Console.WriteLine($"Received message ({d}) to stream {testStreamId:D} from session {header.SessionId:x} term id {header.TermId:x} term offset {header.TermOffset:D} ({length:D}@{offset:D})");

            _subject.OnNext(data);
            // Received the intended message, time to exit the program
            //running.Set(false);
        }
コード例 #5
0
        private void OnParseMessage(IDirectBuffer buffer, int offset, int length, Header header)
        {
            int session = header.SessionId;

            var client = this.clients[session];

            if (client == null)
            {
                Log?.WriteLine($"received message from unknown client: {session}");
                return;
            }

            var buf = new byte[length];

            buffer.GetBytes(offset, buf);
            var message = Encoding.UTF8.GetString(buf);

            client.OnReceiveMessage(message);
        }