whycxzp
2025-05-28 35a1c88cc80ca675f6173648968ab5394b49e31e
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
package com.whyc.webSocket;
 
import com.google.gson.GsonBuilder;
import com.whyc.dto.Response;
 
import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;
 
/**
 * 编译器
 */
public class WebSocketEncoder implements Encoder.Text<Response> {
 
 
    @Override
    public String encode(Response o) throws EncodeException {
        return new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create().toJson(o);
    }
 
    @Override
    public void init(EndpointConfig endpointConfig) {
 
    }
 
    @Override
    public void destroy() {
 
    }
}