Ejemplo n.º 1
0
        /// <summary>
        /// SubscribeStream creates a stream subscription that allows you to read from a stream and receive future writes.
        /// </summary>
        /// <param name="streamId">The stream to subscribe to.</param>
        /// <param name="from">The position to subscribe from.</param>
        /// <param name="cancellationToken">The cancellation token to cancel the subscription.</param>
        /// <returns>A stream subscription.</returns>
        public IStreamSubscription SubscribeStream(string streamId, long from, CancellationToken cancellationToken = default(CancellationToken))
        {
            var watch = _client.SubscribeStream(new SubscribeStreamRequest
            {
                Database = _db,
                Stream   = streamId,
                From     = from,
                Count    = (uint)10, // TODO: allow specification of slice size
            }, _metadata, cancellationToken: cancellationToken);

            return(new StreamSubscription(watch.ResponseStream));
        }