Reputation: 89
I try to make simple chat program base on this example.
import io.netty.channel.ChannelHandlerContext;
public class ChatClientHandler extends ChannelInboundMessageHandlerAdapter<String>
{
}
I get cannot find symbol
error. I'd also tried change SimpleInboundHandlerAdapter
to SimpleInboundHandlerAdapter
but with same result.
Upvotes: 3
Views: 3262
Reputation: 130
The class ChannelInboundMessageHandlerAdapter are not able in the last releases. If you want to use ChannelInboundMessageHandlerAdapter anyway you have to update the netty version to 4.0.0.CR3 In maven you have to add the following dependency in order to work with this class
<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.0.CR3</version>
</dependency>
or even better you can upgrade to the last stable version. At this moment is 4.1.5.Final ...
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.5.Final</version>
</dependency>
and extends of SimpleChannelInboundHandler instead of ChannelInboundMessageHandlerAdapter as showed below:
public class ChatClientHandler extends SimpleChannelInboundHandler<String> {
@Override
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
System.out.println("Te fuiste para lo de Visconti: " + msg);
}
}
keep in mind that channelRead0 method name will be renamed to messageReceived(ChannelHandlerContext, I) in 5.0 version
Upvotes: 2