擴展資料
需要編解碼的才會去用messageReceived,壹般都是使用ChannelRead來讀取的。
SimpleChannelInboundHandler的源代碼妳就知道了,泛型不匹配,不會調用messageReceived的。
另:如果妳特別特別想用SimpleChannelInboundHandler,妳可以這樣搞:public classYouTCPServerHandler extends SimpleChannelInboundHandler<ByteBuf>{...}
因為妳沒有做過任何的編碼解碼,所以妳的泛型是ByteBuf,這樣妳肯定可以使用messageReceived來接收到消息了。