Reputation: 111
I want to implement sending and receiving packets (I use this in OIO)
Step 1: Server -> Client, Packet A
Step 2: Client -> Server, Packet B
Step 3: Server -> Client, Packet C
When server send Packet A to client, Client should send boolean to server. Then if it's true server should send PACKET B to client. I don't know how to implement this with Netty. Please help me.
Upvotes: 0
Views: 816
Reputation: 7983
Note that the methods channelRead
of the ChannelInboundHandler
and the write
and writeAndFlush
methods of the ChannelHandlerContext
takes objects as parameters.
You need to implement your own client and server along with encoders and decoders that receives and sends data based on the packet specifications you have. That is you need to encode Packet A, Packet B and Packet C and send to the client. Client should decode the packets and respond with a boolean which needs to be encoded and sent to the server. Server should then decode and process the boolean.
The above is a lot complicated. You can easily do this by sending JSON or any other form of data over the HTTP protocol because decoders and encoders for this protocol is already supported by netty. All you have to do then is to process the JSON data.
Upvotes: 0