vince
2024-03-04 070b1e9cc8fccd36e7b65720a778ac46e118c792
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
package com.fzzy.protocol.weightyh;
 
import com.fzzy.api.utils.BytesUtil;
import com.ld.io.api.IoServerOption;
import com.ld.io.netty.NettyServer;
import lombok.extern.slf4j.Slf4j;
 
/**
 * 地磅服务启动
 *
 * @author: andy.jia
 * @description:
 * @version:
 */
@Slf4j
public class YhScaleServerEngine {
 
    public static final int port = 19003;
 
    public static NettyServer ioServer = null;
    // 配置消息接收类
    private static MessageConsumer messageConsume = new MessageConsumer();
    // 监听会话的创建与销毁
    private static SessionListener ioSessionListener = new SessionListener();
 
    public static void start() throws InterruptedException {
        // 配置Server的配置
        IoServerOption ioServerOption = new IoServerOption(port);
        // 拆包器配置
        //ioServerOption.setSplitDecoderType(SplitByteDecoderType.DELIMITER_SYMBOL);
        ioServerOption.setDelimiter(BytesUtil.hexStrToBytes("03"));
 
        ioServer = new NettyServer(ioServerOption, messageConsume, ioSessionListener);
        ioServer.startup();
 
        log.info("* ========================");
        log.info("* ");
        log.info("* WEIGHT-SERVER-START,PORT={}", YhScaleServerEngine.port);
        log.info("* ");
        log.info("* ========================");
    }
 
}