After reading this code, NettyClient is used to create a connection (ClientHandler), after the connection is completed ClientHandler.channelActive Netty is called, if you want to send data to the server, you should put some code here. if this connection is received by the message form server, ClientHandler.channelRead is called by Netty, put your code to process the message.
You also need to read the document to find out how the netty encoder / decoder works.
How can I use the returned Future channel from callBack from other parts of my code to read incoming messages?
share those ClientHandler created by NettyClient (string NettyClient.java 29)
Do I need to call callBack again or how can I get an updated channel message?
if a server message arrives, ClientHandler.channelRead is called.
Is it possible to use something like ret.channel () from my code (inside the button event). read () (to accept the last message)?
yes, you could, but not be unclean, play with netty, you write callbacks (when the message arrives, when the message is sent ...), wait until netty calls your code, that is: the driver is net, not you .
last, do you really need such a large library for networking? If not, try this code , it's simple, easy to understand
source share