From 9ad6b0179be4d351105f1507779d4f41a3a41953 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期六, 07 九月 2024 16:57:40 +0800
Subject: [PATCH] 1、完善代码; 2、江海协议时标(tp)实现中的bug修改。

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnit.java |   32 +++++++++++++++++++++++++++-----
 1 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnit.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnit.java
index e0d83d6..ccf2443 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnit.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnit.java
@@ -13,7 +13,7 @@
 
 import com.dy.common.mw.UnitAdapterInterface;
 import com.dy.common.mw.UnitInterface;
-import com.dy.common.mw.UnitStartedCallbackInterface;
+import com.dy.common.mw.UnitCallbackInterface;
 
 @SuppressWarnings("unused")
 public class TcpUnit implements UnitInterface {
@@ -22,6 +22,8 @@
 	private static boolean started = false ;
 	
 	private TcpUnitAdapter adapter ;
+	private TcpIoHandler tcpIoHandler ;
+	private DataCodecFactory dataCodecFactory ;
 	
 	private TcpUnit(){} ;
 	
@@ -61,7 +63,7 @@
 	/**
 	 * 鍚姩妯″潡
 	 */
-	public void start(UnitStartedCallbackInterface callback) throws Exception {
+	public void start(UnitCallbackInterface callback) throws Exception {
 		if(!started){
 			started = true ;
 			/**
@@ -94,7 +96,8 @@
 			//寰楀埌缃戠粶 閫氫俊鏁版嵁杩囨护鍣ㄩ摼
 			DefaultIoFilterChainBuilder chain = acceptor.getFilterChain() ;
 			//缂栬В鐮佽繃婊ゅ櫒
-			chain.addLast("protocol", new ProtocolCodecFilter(new DataCodecFactory(this.adapter)));
+			dataCodecFactory = new DataCodecFactory(this.adapter) ;
+			chain.addLast("protocol", new ProtocolCodecFilter(dataCodecFactory));
 			
 			/*
 			 * 涓�鑸珽xecutorFilter 閮借鏀惧湪ProtocolCodecFilter 杩囨护鍣ㄧ殑鍚庨潰锛�
@@ -106,7 +109,8 @@
 			chain.addLast("exceutor", new ExecutorFilter());
 
 			//涓氬姟閫昏緫澶勭悊鍣紝璐熻矗澶勭悊缃戠粶浼氳瘽鍙婅緭鍏ヨ緭鍑烘暟鎹�
-			acceptor.setHandler(new TcpIoHandler(this.adapter));
+			tcpIoHandler = new TcpIoHandler(this.adapter) ;
+			acceptor.setHandler(tcpIoHandler) ;
 
 			boolean isException = false ;
 			try {
@@ -129,8 +133,26 @@
 		}
 	}
 
+	/**
+	 * 鍋滄妯″潡杩愯锛屽皢涓嶅啀鎺ュ叆TCP缃戠粶杩炴帴锛屽苟鎶婂凡缁弔cp杩炴帴鐨勫叏閮ㄦ柇杩炴帴
+	 * @param callback
+	 * @throws Exception
+	 */
 	@Override
-	public void stop(UnitStartedCallbackInterface callback) throws Exception {
+	public void stop(UnitCallbackInterface callback) throws Exception {
+		this.tcpIoHandler.stop();
+		this.dataCodecFactory.stop();
+		this.adapter.newUnitStopCallback().callback();
+		callback.call(null);
+	}
+
+	/**
+	 * 瑙i櫎鍋滄锛屾仮澶峊CP鏈嶅姟杩愯
+	 * @throws Exception
+	 */
+	public void recover() throws Exception {
+		this.tcpIoHandler.recover();
+		this.dataCodecFactory.recover();
 	}
 	
 

--
Gitblit v1.8.0