Ejemplo n.º 1
0
            public override void WriteBuffer(IList <ByteBuffer> buffers)
            {
                int length = 0;

                foreach (ByteBuffer buffer in buffers)
                {
                    length = length + buffer.Length;
                }
                ByteBuffer byteBuffer = new ByteBuffer(length, false, false);

                foreach (ByteBuffer buffer1 in buffers)
                {
                    Buffer.BlockCopy(buffer1.Buffer, buffer1.Offset, byteBuffer.Buffer, byteBuffer.Length, buffer1.Length);
                    byteBuffer.Append(buffer1.Length);
                    buffer1.Dispose();
                }
                base.WriteBuffer(byteBuffer);
            }
Ejemplo n.º 2
0
 unsafe public void Write(byte[] buffer, int offset, int count, Action <object> callback, object state)
 {
     if (this.parent.encoding)
     {
         this.WriteTransferFrame(buffer, offset, count, callback, state);
     }
     else
     {
         ByteBuffer byteBuffer = ByteBuffer.Wrap(Frame.HeaderSize);
         AmqpBitConverter.WriteUInt(byteBuffer, (uint)(Frame.HeaderSize + count));
         byteBuffer.Append(4);
         this.AsyncIO.Writer.WriteBuffer(
             byteBuffer.Array,
             new ArraySegment <byte>[] { new ArraySegment <byte>(buffer, offset, count) },
             callback,
             state);
     }
 }
Ejemplo n.º 3
0
 void AdjustBufferForNextRead(ByteBuffer buffer)
 {
     if (buffer.Length > 0)
     {
         int oldLength = buffer.Length;
         Buffer.BlockCopy(
             buffer.Buffer,
             buffer.Offset,
             buffer.Buffer,
             0,
             oldLength);
         buffer.Reset();
         buffer.Append(oldLength);
     }
     else
     {
         buffer.Reset();
     }
 }
Ejemplo n.º 4
0
            unsafe void WriteTransferFrame(byte[] buffer, int offset, int count, Action <object> callback, object state)
            {
                ArraySegment <byte>[] packet = new ArraySegment <byte>[]
                {
                    Data.GetEncodedPrefix(count),
                    new ArraySegment <byte>(buffer, offset, count)
                };

                int        payloadSize = packet[0].Count + packet[1].Count;
                ByteBuffer byteBuffer  = ByteBuffer.Wrap(128);
                int        index       = 4;

                fixed(byte *p = byteBuffer.Buffer)
                {
                    p[index++] = 2;
                    p[index++] = p[index++] = p[index++] = 0;

                    p[index++] = 0;
                    p[index++] = (byte)FormatCode.SmallULong;
                    p[index++] = (byte)Transfer.Code;
                    p[index++] = (byte)FormatCode.List8;
                    int listSizeIndex = index++;

                    p[index++] = 11;

                    // handle
                    p[index++] = (byte)FormatCode.UInt0;

                    // delivery id
                    uint  deliveryId = (uint)this.sn++;
                    byte *d          = (byte *)&deliveryId;

                    p[index++] = (byte)FormatCode.UInt;
                    p[index++] = d[3];
                    p[index++] = d[2];
                    p[index++] = d[1];
                    p[index++] = d[0];

                    // delivery tag
                    p[index++] = (byte)FormatCode.Binary8;
                    p[index++] = 0;

                    // message format
                    p[index++] = (byte)FormatCode.UInt0;

                    // settled
                    p[index++] = (byte)FormatCode.BooleanTrue;

                    // more
                    p[index++] = (byte)FormatCode.BooleanFalse;

                    // rcv settle mode, state, resume, abort
                    p[index++] = p[index++] = p[index++] = p[index++] = (byte)FormatCode.Null;

                    // batchable
                    p[index++] = (byte)FormatCode.BooleanTrue;

                    // write list size
                    p[listSizeIndex] = (byte)(index - listSizeIndex);

                    // write the frame size
                    int frameSize = index + payloadSize;

                    d    = (byte *)&frameSize;
                    p[0] = d[3];
                    p[1] = d[2];
                    p[2] = d[1];
                    p[3] = d[0];
                }

                byteBuffer.Append(index);
                this.AsyncIO.Writer.WriteBuffer(byteBuffer.Array, packet, callback, state);
            }
Ejemplo n.º 5
0
 void AdjustBufferForNextRead(ByteBuffer buffer)
 {
     if (buffer.Length > 0)
     {
         int oldLength = buffer.Length;
         Buffer.BlockCopy(
             buffer.Buffer,
             buffer.Offset,
             buffer.Buffer,
             0,
             oldLength);
         buffer.Reset();
         buffer.Append(oldLength);
     }
     else
     {
         buffer.Reset();
     }
 }