aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/imsonmia/epqapi/messaging/MessageDecoder.java
blob: 78f2e2d6e215f02acad11775b90d4fe19515a6ce (plain)
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
package me.imsonmia.epqapi.messaging;

import com.google.gson.Gson;

import jakarta.websocket.DecodeException;
import jakarta.websocket.Decoder;
import jakarta.websocket.EndpointConfig;

public class MessageDecoder implements Decoder.Text<Message> {
    private static Gson gson = new Gson();
    @Override
    public Message decode(String message) throws DecodeException {
        return gson.fromJson(message, Message.class);
    }
    @Override
    public void destroy() {
        Text.super.destroy();
    }
    @Override
    public void init(EndpointConfig endpointConfig) {
        Text.super.init(endpointConfig);
    }
    @Override
    public boolean willDecode(String s) {
        // TODO Auto-generated method stub
        return (s != null);
    }
}