648540858
2022-06-14 e0344ccf9725fe3d22a90ab11257396071e7f55f
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.genersoft.iot.vmp.service.bean;
 
/**
 * @author lin
 */
public class WvpRedisMsg {
 
    public static WvpRedisMsg getInstance(String fromId, String toId, String type, String cmd, String serial, String content){
        WvpRedisMsg wvpRedisMsg = new WvpRedisMsg();
        wvpRedisMsg.setFromId(fromId);
        wvpRedisMsg.setToId(toId);
        wvpRedisMsg.setType(type);
        wvpRedisMsg.setCmd(cmd);
        wvpRedisMsg.setSerial(serial);
        wvpRedisMsg.setContent(content);
        return wvpRedisMsg;
    }
 
    private String fromId;
 
    private String toId;
    /**
     * req 请求, res 回复
     */
    private String type;
    private String cmd;
 
    /**
     * 消息的ID
     */
    private String serial;
    private Object content;
 
    private final static String requestTag = "req";
    private final static String responseTag = "res";
 
    public static WvpRedisMsg getRequestInstance(String fromId, String toId, String cmd, String serial, Object content) {
        WvpRedisMsg wvpRedisMsg = new WvpRedisMsg();
        wvpRedisMsg.setType(requestTag);
        wvpRedisMsg.setFromId(fromId);
        wvpRedisMsg.setToId(toId);
        wvpRedisMsg.setCmd(cmd);
        wvpRedisMsg.setSerial(serial);
        wvpRedisMsg.setContent(content);
        return wvpRedisMsg;
    }
 
    public static WvpRedisMsg getResponseInstance() {
        WvpRedisMsg wvpRedisMsg = new WvpRedisMsg();
        wvpRedisMsg.setType(responseTag);
        return wvpRedisMsg;
    }
 
    public static WvpRedisMsg getResponseInstance(String fromId, String toId, String cmd, String serial, Object content) {
        WvpRedisMsg wvpRedisMsg = new WvpRedisMsg();
        wvpRedisMsg.setType(responseTag);
        wvpRedisMsg.setFromId(fromId);
        wvpRedisMsg.setToId(toId);
        wvpRedisMsg.setCmd(cmd);
        wvpRedisMsg.setSerial(serial);
        wvpRedisMsg.setContent(content);
        return wvpRedisMsg;
    }
 
    public static boolean isRequest(WvpRedisMsg wvpRedisMsg) {
        return requestTag.equals(wvpRedisMsg.getType());
    }
 
    public String getSerial() {
        return serial;
    }
 
    public void setSerial(String serial) {
        this.serial = serial;
    }
 
    public String getFromId() {
        return fromId;
    }
 
    public void setFromId(String fromId) {
        this.fromId = fromId;
    }
 
    public String getToId() {
        return toId;
    }
 
    public void setToId(String toId) {
        this.toId = toId;
    }
 
    public String getType() {
        return type;
    }
 
    public void setType(String type) {
        this.type = type;
    }
 
    public String getCmd() {
        return cmd;
    }
 
    public void setCmd(String cmd) {
        this.cmd = cmd;
    }
 
    public Object getContent() {
        return content;
    }
 
    public void setContent(Object content) {
        this.content = content;
    }
}