0

我需要在客户端用java构造一个字符串并将其发送到服务器进行解码。

我需要client name他是否要注册("Subscribe""Unsubscribe")。

我正在使用 hashmap 来实现它,客户端名称是键和一个以客户端数据作为值的类。

我正在使用UDP.

那么你认为我应该使用什么来编码和解码请求的最佳方式是什么?

谢谢。

4

2 回答 2

2

You could use any of the already available formats:

If any of them seem to heavy-weight for you. You could make a simple custom format just for your application. But if I would be in your shoes I would go with with JSON, as you mentioned is 'just' a school assignment, so you should learn something.

Good luck

于 2013-06-03T11:20:45.930 回答
2

使用 JSON:

{"client-name": "cow", "action":"subscribe"}
于 2013-06-03T11:02:29.210 回答