Agnos.Transports.BaseTransport.EndWrite C# (CSharp) Method

EndWrite() public method

public EndWrite ( ) : void
return void
        public virtual void EndWrite()
        {
            #if AGNOS_TRANSPORT_DEBUG
            System.Console.WriteLine("Transport.EndWrite");
            #endif
            AssertBeganWrite ();
            if (wbuffer.Length > 0) {
                writeSInt32(outStream, wseq);

                if (compressionThreshold > 0 && wbuffer.Length >= compressionThreshold) {
                    compressionBuffer.Position = 0;
                    compressionBuffer.SetLength (0);
                    using (DeflateStream dfl = new DeflateStream (compressionBuffer, CompressionMode.Compress, true)) {
                        wbuffer.WriteTo (dfl);
                    }
            #if AGNOS_TRANSPORT_DEBUG
                    //System.Console.WriteLine("Transport.EndWrite seq={0}, len={1}, uncomp={2}", wseq, compressionBuffer.Length, wbuffer.Length);
                    System.Console.WriteLine(">> " + repr(wbuffer.ToArray()));
            #endif
                    writeSInt32 (outStream, (int)compressionBuffer.Length); // packet length
                    writeSInt32 (outStream, (int)wbuffer.Length); // uncompressed length
                    compressionBuffer.WriteTo (outStream);
                }
                else {
            #if AGNOS_TRANSPORT_DEBUG
                    System.Console.WriteLine(">> seq={0}, len={1}, uncomp=0", wseq, wbuffer.Length);
                    System.Console.WriteLine(">> " + repr(wbuffer.ToArray()));
            #endif
                    writeSInt32 (outStream, (int)wbuffer.Length); // packet length
                    writeSInt32 (outStream, 0); // 0 means no compression
                    wbuffer.WriteTo (outStream);
                }

                outStream.Flush ();
            }

            wbuffer.Position = 0;
            wbuffer.SetLength (0);
            wlock.Release ();
        }