Exemple #1
0
        protected internal override void Encode(ChannelHandlerContext ctx, FileHeader msg, ByteBuf @out)
        {
            string name = msg.FileName();

            sbyte[] bytes = UTF8.encode(name);
            @out.writeInt(bytes.Length);
            @out.writeBytes(bytes);
            @out.writeInt(msg.RequiredAlignment());
        }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void encode(io.netty.buffer.ByteBuf buffer, io.netty.handler.stream.ChunkedInput<io.netty.buffer.ByteBuf> marshal) throws Exception
        private static void Encode(ByteBuf buffer, ChunkedInput <ByteBuf> marshal)
        {
            while (!marshal.EndOfInput)
            {
                ByteBuf tmp = marshal.readChunk(UnpooledByteBufAllocator.DEFAULT);
                if (tmp != null)
                {
                    buffer.writeBytes(tmp);
                    tmp.release();
                }
            }
        }
Exemple #3
0
 public static void Marshal(ByteBuf buffer, string @string)
 {
     if (string.ReferenceEquals(@string, null))
     {
         buffer.writeInt(NULL_STRING_LENGTH);
     }
     else
     {
         sbyte[] bytes = @string.GetBytes(UTF_8);
         buffer.writeInt(bytes.Length);
         buffer.writeBytes(bytes);
     }
 }
Exemple #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDecodeMaxSizeChunk()
        public virtual void ShouldDecodeMaxSizeChunk()
        {
            sbyte[] message = new sbyte[0xFFFF];

            ByteBuf input = buffer();

            input.writeShort(message.Length);
            input.writeBytes(message);

            assertTrue(_channel.writeInbound(input));
            assertTrue(_channel.finish());

            assertEquals(1, _channel.inboundMessages().size());
            assertByteBufEquals(wrappedBuffer(message), _channel.readInbound());
        }
Exemple #5
0
 public override WritableChannel Put(sbyte[] value, int length)
 {
     @delegate.writeBytes(value, 0, length);
     return(this);
 }