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("* ========================");
|
}
|
|
}
|