-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRequest.java
More file actions
60 lines (46 loc) · 1.45 KB
/
Copy pathRequest.java
File metadata and controls
60 lines (46 loc) · 1.45 KB
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
package com.modulecode.net.impl;
import com.modulecode.net.IConnection;
import com.modulecode.net.IMessage;
import com.modulecode.net.IRequest;
import com.modulecode.utils.JacksonUtils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
public class Request implements IRequest {
//已经和客户端建立好的连接
private IConnection conn;
private IMessage message;
public Request(IConnection conn, IMessage message) {
this.conn = conn;
this.message = message;
}
//得到当前连接
@Override
public IConnection getConnection() {
return conn;
}
@Override
public byte[] getData() {
return this.message.getData();
}
@Override
public int getMsgID() {
return this.message.getMsgID();
}
@Override
public String getString(String charsetName) throws UnsupportedEncodingException {
return new String(this.message.getData(), charsetName);
}
// @Override
// public <T> T convertClass(Class<T> clazz) throws IOException {
// return convertClass(getString("utf-8"), clazz);
// }
@Override
public <T> T convertClass(String charsetName, Class<T> clazz) throws IOException {
return convertClass(getString(charsetName), clazz);
}
@Override
public <T> T convertClass(Class<T> clazz) throws IOException {
return JacksonUtils.json2Bean(getString("utf-8"), clazz);
}
//获取数据
}