//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static byte[] chunk(int maxChunkSize, byte[][] messages) throws java.io.IOException public static sbyte[] Chunk(int maxChunkSize, sbyte[][] messages) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final ByteBuffer outputBuffer = ByteBuffer.allocate(1024 * 8); ByteBuffer outputBuffer = ByteBuffer.allocate(1024 * 8); Channel ch = mock(typeof(Channel)); when(ch.alloc()).thenReturn(UnpooledByteBufAllocator.DEFAULT); when(ch.writeAndFlush(any(), Null)).then(inv => { ByteBuf buf = inv.getArgument(0); outputBuffer.limit(outputBuffer.position() + buf.readableBytes()); buf.readBytes(outputBuffer); buf.release(); return(null); }); int maxBufferSize = maxChunkSize + CHUNK_HEADER_SIZE; ChunkedOutput @out = new ChunkedOutput(ch, maxBufferSize, maxBufferSize, TransportThrottleGroup.NO_THROTTLE); foreach (sbyte[] message in messages) { @out.BeginMessage(); @out.WriteBytes(message, 0, message.Length); @out.MessageSucceeded(); } @out.Flush(); @out.Dispose(); sbyte[] bytes = new sbyte[outputBuffer.limit()]; outputBuffer.position(0); outputBuffer.get(bytes); return(bytes); }
private Future <Void> Write(object msg, bool flush) { if (_disposed) { throw new System.InvalidOperationException("sending on disposed channel"); } if (_channel.Active) { if (flush) { return(_channel.writeAndFlush(msg)); } else { return(_channel.write(msg)); } } else { Promise <Void> promise = _eventLoop.newPromise(); System.Action <io.netty.channel.Channel, object> writer; if (flush) { writer = (_channel, message) => chain(_channel.writeAndFlush(msg), promise); } else { writer = (_channel, message) => chain(_channel.write(msg), promise); } DeferredWrite(msg, _fChannel, promise, true, writer); return(promise); } }
public override Future <Void> WriteAndFlush(object msg) { CheckDisposed(); return(_channel.writeAndFlush(msg)); }