| New file | 
 |  |  | 
 |  |  | package com.dy.rtuMw3rd.tcp4Bjnl; | 
 |  |  |  | 
 |  |  | import org.apache.mina.core.session.IoSession; | 
 |  |  | import org.apache.mina.filter.codec.ProtocolCodecFactory; | 
 |  |  | import org.apache.mina.filter.codec.ProtocolDecoder; | 
 |  |  | import org.apache.mina.filter.codec.ProtocolEncoder; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * @Author: liurunyu | 
 |  |  |  * @Date: 2025/03/18 14:20 | 
 |  |  |  * @Description | 
 |  |  |  */ | 
 |  |  | public class NetDataCodecFactory implements ProtocolCodecFactory { | 
 |  |  |     private ProtocolEncoder encoder; | 
 |  |  |     private ProtocolDecoder decoder; | 
 |  |  |  | 
 |  |  |     public NetDataCodecFactory() { | 
 |  |  |         encoder = new NetDataEncoder(); | 
 |  |  |         decoder = new NetDataDecoder(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 得到协议编码器 | 
 |  |  |      * @param ioSession 网络会话 | 
 |  |  |      * @return 协议编码器 | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public ProtocolEncoder getEncoder(IoSession ioSession) { | 
 |  |  |         return encoder; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 得到协议解码器 | 
 |  |  |      * @param ioSession 网络会话 | 
 |  |  |      * @return 协议解码器 | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public ProtocolDecoder getDecoder(IoSession ioSession) { | 
 |  |  |         return decoder; | 
 |  |  |     } | 
 |  |  | } |