From 016d28eba8f0d8f8632828c4589a3b39274a5f02 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期三, 07 五月 2025 14:58:37 +0800 Subject: [PATCH] 1、协议命令生成器增量开发,增加实现几个设置与对应的查询命令; 2、修改陈旧bug。 --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataCodecFactory.java | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataCodecFactory.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataCodecFactory.java new file mode 100644 index 0000000..284dcb6 --- /dev/null +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataCodecFactory.java @@ -0,0 +1,39 @@ +package com.dy.common.mw.channel.tcp; + +import org.apache.mina.filter.codec.ProtocolCodecFactory; +import org.apache.mina.filter.codec.ProtocolEncoder; +import org.apache.mina.filter.codec.ProtocolDecoder; +import org.apache.mina.core.session.IoSession; + +public class DataCodecFactory implements ProtocolCodecFactory { + + private TcpUnitAdapter adapter ; + private boolean stop = false ;//涓簍rue鏃讹紝鍋滄TCP鏈嶅姟锛屽苟鎶婂凡缁廡CP杩炴帴鏂繛鎺� + + public DataCodecFactory(TcpUnitAdapter adapter) { + this.adapter = adapter ; + } + + public void stop(){ + stop = true ; + } + + public void recover(){ + this.stop = false ; + } + + + public ProtocolEncoder getEncoder(IoSession ioSession) { + if(stop){ + ioSession.closeNow() ; + } + return new DataEncoder(); + } + + public ProtocolDecoder getDecoder(IoSession ioSession) { + if(stop){ + ioSession.closeNow() ; + } + return new DataDecoder(adapter.newPrefixedDataAvailableHandle()); + } +} -- Gitblit v1.8.0