Esempio n. 1
0
        public void Signal <T>(T payload)
        {
            ThrowIfDisposed();

            var hydrator = settings.Hydrator;

            using (Stream dehydreated = hydrator.Dehydrate(payload))
            {
                byte[] buffer = new byte[0x100];
                int    size   = 0;
                do
                {
                    size = ReadBytes(buffer, dehydreated);

                    var header = HeaderPacktToByteArray(new HeaderPacket
                    {
                        Final = size < buffer.Length,
                        Size  = size
                    });

                    OutStream.Write(header, 0, header.Length);
                    if (size > 0)
                    {
                        OutStream.Write(buffer, 0, size);
                    }
                } while (size != 0);
            }

            OutStream.Flush();

            if (settings.WaitForDrain)
            {
                OutStream.WaitForPipeDrain();
            }
        }