예제 #1
0
        public StreamSendRequest(PendingSendStream stream, long length)
        {
            Require.NotNull(stream, "stream");

            _stream = stream;
            _length = length;
        }
예제 #2
0
        public int RegisterStream(Stream stream, string streamName, string contentType, int? associationId)
        {
            Require.NotNull(stream, "stream");

            if (_streams.Count == MaxAssociationId)
                throw new ProtoChannelException("No stream association ID's are available");

            stream.Position = 0;

            var protoStream = new PendingSendStream(
                stream.Length, streamName, contentType, GetNextAssociationId(associationId), stream
            );

            _streams.Add(protoStream.AssociationId, protoStream);

            return protoStream.AssociationId;
        }
예제 #3
0
        public int RegisterStream(Stream stream, string streamName, string contentType, StreamDisposition disposition, int? associationId)
        {
            Require.NotNull(stream, "stream");

            if (_streams.Count == MaxAssociationId)
                throw new ProtoChannelException("No stream association ID's are available");

            // Setting the position throws when the stream cannot be seeked,
            // even when the position already is 0.

            if (stream.Position != 0)
                stream.Position = 0;

            var protoStream = new PendingSendStream(
                stream.Length, streamName, contentType, disposition, GetNextAssociationId(associationId), stream
            );

            _streams.Add(protoStream.AssociationId, protoStream);

            return protoStream.AssociationId;
        }
예제 #4
0
        private void RemoveStream(PendingSendStream stream)
        {
            // The stream is not removed from the queue. Processing the queue
            // knows that it should skip disposed streams.

            _streams.Remove(stream.AssociationId);

            stream.Dispose();
        }
예제 #5
0
        public void RemoveStream(PendingSendStream stream)
        {
            Require.NotNull(stream, "stream");

            if (_streams.ContainsKey(stream.AssociationId))
            {
                // The stream is not removed from the queue. Processing the queue
                // knows that it should skip disposed streams.

                _streams.Remove(stream.AssociationId);

                stream.Dispose();
            }
        }