Exemplo n.º 1
0
        private void WriteStreamPackageHeader(StreamSendRequest request, StreamPackageType streamPackageType)
        {
            uint header = (uint)streamPackageType | (uint)request.Stream.AssociationId << 3;

            var buffer = BitConverterEx.GetNetworkBytes(header);

            Write(buffer, 0, buffer.Length);
        }
Exemplo n.º 2
0
        private void SendStreamEnd(StreamSendRequest request, bool success)
        {
            _sendStreamManager.RemoveStream(request.Stream);

            long packageStart = BeginSendPackage();

            WriteStreamPackageHeader(request, success ? StreamPackageType.EndStream : StreamPackageType.StreamFailed);

            EndSendPackage(PackageType.Stream, packageStart, false);

            RaiseEvent(request.Stream, StreamTransferEventType.End);
        }
Exemplo n.º 3
0
        private void SendStreamEnd(StreamSendRequest request)
        {
            long packageStart = BeginSendPackage();

            WriteStreamPackageHeader(request, StreamPackageType.EndStream);

            EndSendPackage(PackageType.Stream, packageStart, false);
        }
Exemplo n.º 4
0
        private void SendStreamData(StreamSendRequest request)
        {
            // Send the stream data package.

            long packageStart = BeginSendPackage();

            WriteStreamPackageHeader(request, StreamPackageType.StreamData);

            // Write the stream data. If this fails, we send a stream
            // failure instead.

            try
            {
                WriteStream(request.Stream.Stream, request.Length);

                RaiseEvent(request.Stream, StreamTransferEventType.Transfer);
            }
            catch (Exception ex)
            {
                // If the send stream failed, back up and send the stream
                // failed package.

                Log.Warn("Exception while reading from stream", ex);

                WriteLength = WritePosition = packageStart;

                SendStreamEnd(request, false);

                return;
            }

            request.Stream.Position += request.Length;

            // And send the package.

            EndSendPackage(PackageType.Stream, packageStart, false);
        }
Exemplo n.º 5
0
        private void SendStreamData(StreamSendRequest request)
        {
            // Send the stream data package.

            long packageStart = BeginSendPackage();

            WriteStreamPackageHeader(request, StreamPackageType.StreamData);

            // Write the stream data.

            WriteStream(request.Stream.Stream, request.Length);

            // And send the package.

            EndSendPackage(PackageType.Stream, packageStart, false);
        }