Take advantage of the new method in ChannelInboundStreamHandlerAdapter
This commit is contained in:
parent
3584da2dad
commit
633fada6ec
@ -54,9 +54,10 @@ public class DiscardClientHandler extends ChannelInboundStreamHandlerAdapter {
|
||||
|
||||
|
||||
@Override
|
||||
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx)
|
||||
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in)
|
||||
throws Exception {
|
||||
// Server is supposed to send nothing. Therefore, do nothing.
|
||||
// Server is supposed to send nothing, but if it sends something, discard it.
|
||||
in.clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.discard;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.channel.ChannelInboundHandlerContext;
|
||||
import io.netty.channel.ChannelInboundStreamHandlerAdapter;
|
||||
|
||||
@ -31,10 +32,10 @@ public class DiscardServerHandler extends ChannelInboundStreamHandlerAdapter {
|
||||
|
||||
|
||||
@Override
|
||||
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx)
|
||||
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in)
|
||||
throws Exception {
|
||||
// Discard the received data silently.
|
||||
ctx.inbound().byteBuffer().clear();
|
||||
in.clear();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user