shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.walker.tcp.websocket;
 
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.walker.infrastructure.utils.JsonUtils;
import com.walker.tcp.TcpRequest;
import com.walker.tcp.data.AbstractStringRequest;
import com.walker.tcp.util.WebSocketUtils;
 
@TcpRequest("hello")
public class HelloRequest extends AbstractStringRequest {
 
    /**
     *
     */
    private static final long serialVersionUID = 5322523893566046088L;
 
    private String summary;
 
    public String getSummary() {
        return summary;
    }
 
    @Override
    protected void translateData(String source) {
        try {
            ObjectNode objectNode = JsonUtils.jsonStringToObjectNode(source);
            this.setName(objectNode.get(WebSocketUtils.WEB_SOCKET_KEY_UID).asText());
            this.summary = objectNode.get("summary").textValue();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
//        JSONObject json = JSONObject.parseObject(source);
//        this.setName(json.getString(WebSocketUtils.WEB_SOCKET_KEY_UID));
//        this.summary = json.getString("summary");
    }
 
    @Override
    public String getProtocolNum() {
        return "hello";
    }
 
}