Jee Seok Yoon
Jee Seok Yoon

Reputation: 4816

ByteBuf with JSON?

I am a student who just started using Netty!

I am building a server that communicates with android and iOS. The primary task of my server will be sending and recieving JSON files with images(10 jpegs) and texts(less than 100 character).

My server's framework is Netty.

I built my server from "HttpUploadServer" from the Netty 4.0.6 example jar. As my server's primary task is to upload and download JSON files, I only used multipart POST part from the example.

So here is my question.

Netty's HttpRequestEncoder and HttpResponseDecoder turns Http requests into ByteBuf and ByteBuf to responses.

However, what happens when I try to communicate with JSON? Does the encoder and decoder turn JSON into a ByteBuf and sends it?

What is the normal way Netty users send and recieve JSON through HTTP?

Upvotes: 0

Views: 2018

Answers (1)

user1998034
user1998034

Reputation: 44

For sending and receiving JSON messages, you don't need to add any Handlers. Http Encoders/Decoders are enough.

Here is a example that uses JSON to send and receive.

http://kevinwebber.ca/multiplayer-tic-tac-toe-in-java-using-the-websocket-api-netty-nio-and-jquery/

Regards,
Rama Krishna.

Upvotes: 2

Related Questions